问题,我正在使用 i18next,一切都很好,除了复数翻译。
复数翻译适用于某些语言,但不适用于其他语言。
例如,克罗地亚语不起作用。我添加了一些日志语句,发现它没有使用翻译键“name_plural”,而是使用“name_plural_5”..
它与这段代码有关:
var pluralKey = ns + o.nsseparator + key + o.pluralSuffix;
var pluralExtension = pluralExtensions.get(lngs[0], options.count);
if (pluralExtension >= 0) {
pluralKey = pluralKey + '_' + pluralExtension;
} else if (pluralExtension === 1) {
pluralKey = ns + o.nsseparator + key; // singular
}
其中引用了这个复数扩展名:
"hr": {
"name": "Croatian",
"numbers": [
1,
2,
5
],
"plurals": function(n) {
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
}
},
作为参考,英语看起来像这样:
"en": {
"name": "English",
"numbers": [
1,
2
],
"plurals": function(n) {
return Number(n != 1);
}
},
现在谁能告诉我这意味着什么?我是否需要为此语言提供多个复数翻译,为什么?