Don't create globals in i18n.js
This commit is contained in:
parent
0d10b5c9c4
commit
88a9e13510
|
@ -186,7 +186,7 @@ I18n.interpolate = function(message, options) {
|
|||
value = "[missing " + placeholder + " value]";
|
||||
}
|
||||
|
||||
regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}"));
|
||||
var regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}"));
|
||||
message = message.replace(regex, value);
|
||||
}
|
||||
|
||||
|
@ -469,14 +469,14 @@ I18n.toPercentage = function(number, options) {
|
|||
};
|
||||
|
||||
I18n.pluralizer = function(locale) {
|
||||
pluralizer = this.pluralizationRules[locale];
|
||||
var pluralizer = this.pluralizationRules[locale];
|
||||
if (pluralizer !== undefined) return pluralizer;
|
||||
return this.pluralizationRules["en"];
|
||||
};
|
||||
|
||||
I18n.findAndTranslateValidNode = function(keys, translation) {
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = keys[i];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
if (this.isValidNode(translation, key)) return translation[key];
|
||||
}
|
||||
return null;
|
||||
|
@ -497,9 +497,9 @@ I18n.pluralize = function(count, scope, options) {
|
|||
options = this.prepareOptions(options);
|
||||
options.count = count.toString();
|
||||
|
||||
pluralizer = this.pluralizer(this.currentLocale());
|
||||
key = pluralizer(Math.abs(count));
|
||||
keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key];
|
||||
var pluralizer = this.pluralizer(this.currentLocale());
|
||||
var key = pluralizer(Math.abs(count));
|
||||
var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key];
|
||||
|
||||
message = this.findAndTranslateValidNode(keys, translation);
|
||||
if (message == null) message = this.missingTranslation(scope, keys[0]);
|
||||
|
|
Loading…
Reference in New Issue