mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Don't create globals in i18n.js
This commit is contained in:
parent
0d10b5c9c4
commit
88a9e13510
1 changed files with 7 additions and 7 deletions
|
@ -186,7 +186,7 @@ I18n.interpolate = function(message, options) {
|
||||||
value = "[missing " + placeholder + " value]";
|
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);
|
message = message.replace(regex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,14 +469,14 @@ I18n.toPercentage = function(number, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
I18n.pluralizer = function(locale) {
|
I18n.pluralizer = function(locale) {
|
||||||
pluralizer = this.pluralizationRules[locale];
|
var pluralizer = this.pluralizationRules[locale];
|
||||||
if (pluralizer !== undefined) return pluralizer;
|
if (pluralizer !== undefined) return pluralizer;
|
||||||
return this.pluralizationRules["en"];
|
return this.pluralizationRules["en"];
|
||||||
};
|
};
|
||||||
|
|
||||||
I18n.findAndTranslateValidNode = function(keys, translation) {
|
I18n.findAndTranslateValidNode = function(keys, translation) {
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
key = keys[i];
|
var key = keys[i];
|
||||||
if (this.isValidNode(translation, key)) return translation[key];
|
if (this.isValidNode(translation, key)) return translation[key];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -497,9 +497,9 @@ I18n.pluralize = function(count, scope, options) {
|
||||||
options = this.prepareOptions(options);
|
options = this.prepareOptions(options);
|
||||||
options.count = count.toString();
|
options.count = count.toString();
|
||||||
|
|
||||||
pluralizer = this.pluralizer(this.currentLocale());
|
var pluralizer = this.pluralizer(this.currentLocale());
|
||||||
key = pluralizer(Math.abs(count));
|
var key = pluralizer(Math.abs(count));
|
||||||
keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key];
|
var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key];
|
||||||
|
|
||||||
message = this.findAndTranslateValidNode(keys, translation);
|
message = this.findAndTranslateValidNode(keys, translation);
|
||||||
if (message == null) message = this.missingTranslation(scope, keys[0]);
|
if (message == null) message = this.missingTranslation(scope, keys[0]);
|
||||||
|
|
Loading…
Reference in a new issue