Skip to content

Commit

Permalink
Account for change to Transifex plural forms
Browse files Browse the repository at this point in the history
Transifex has added a "many" form to es, fr, and it.
  • Loading branch information
matthew-white committed May 30, 2022
1 parent 0bd99bb commit 70a60ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/util/transifex.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const locales = {
en: {},
cs: {},
de: {},
es: {},
fr: { pluralCategories: ['one', 'other'] },
es: { pluralCategories: ['one', 'many', 'other'] },
fr: {},
id: {},
it: {},
it: { pluralCategories: ['one', 'many', 'other'] },
ja: { warnVariableSeparator: false },
sw: {}
};
Expand All @@ -30,7 +30,9 @@ const sourceLocale = 'en';
for (const [locale, options] of Object.entries(locales)) {
const normalized = { ...defaults, ...options };

if (normalized.pluralCategories == null) {
if (normalized.pluralCategories != null) {
normalized.pluralCategories = [...normalized.pluralCategories].sort();
} else {
const pluralRules = new Intl.PluralRules([locale]);
normalized.pluralCategories = pluralRules.resolvedOptions().pluralCategories;
}
Expand Down
5 changes: 5 additions & 0 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ const pluralizationRules = {
*/
return 2;
},
// es, fr, and it have three plural forms in Transifex: one, many, and other.
// However, we never use "many".
es: (count) => (count === 1 ? 0 : 2),
id: noPlural,
ja: noPlural
};
pluralizationRules.fr = pluralizationRules.es;
pluralizationRules.it = pluralizationRules.es;



Expand Down

0 comments on commit 70a60ee

Please sign in to comment.