FIX: locale fallback with pluralized strings

This commit is contained in:
Régis Hanol
2017-02-28 10:02:29 +01:00
parent 54577db8a4
commit 5738253998
2 changed files with 42 additions and 9 deletions

View File

@@ -151,7 +151,7 @@ I18n.translate = function(scope, options) {
try {
if (typeof translation === "object") {
if (typeof options.count === "number") {
return this.pluralize(options.count, scope, options);
return this.pluralize(translation, scope, options);
} else {
return translation;
}
@@ -258,16 +258,11 @@ I18n.findAndTranslateValidNode = function(keys, translation) {
return null;
};
I18n.pluralize = function(count, scope, options) {
var translation;
try { translation = this.lookup(scope, options); } catch (error) {}
if (!translation) { return this.missingTranslation(scope); }
I18n.pluralize = function(translation, scope, options) {
options = this.prepareOptions(options);
options.count = count.toString();
var count = options.count.toString();
var pluralizer = this.pluralizer(this.currentLocale());
var pluralizer = this.pluralizer(options.locale || this.currentLocale());
var key = pluralizer(Math.abs(count));
var keys = ((typeof key === "object") && (key instanceof Array)) ? key : [key];