safely handle keys which aren't strings

This commit is contained in:
ansuz 2017-02-21 12:29:47 +01:00
parent 84b64da76d
commit 5276dac7cc
1 changed files with 7 additions and 3 deletions

View File

@ -79,9 +79,13 @@ define(req, function(Default, Language) {
messages._getKey = function (key, argArray) {
if (!messages[key]) { return '?'; }
var text = messages[key];
return text.replace(/\{(\d+)\}/g, function (str, p1) {
return argArray[p1] || null;
});
if (typeof(text) === 'string') {
return text.replace(/\{(\d+)\}/g, function (str, p1) {
return argArray[p1] || null;
});
} else {
return text;
}
};
// Add handler to the language selector