Skip to content

Commit 102e7ad

Browse files
authored
Revert plural category sort removal of mozilla#3874 (mozilla#3882)
1 parent 225b58a commit 102e7ad

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

translate/src/utils/message/getPluralCategories.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { CLDR_PLURALS } from '../constants';
2+
13
export function getPluralCategories(code: string): Intl.LDMLPluralRule[] {
24
// These special cases should be occasionally pruned on CLDR updates
35
switch (new Intl.Locale(code).language) {
@@ -38,6 +40,12 @@ export function getPluralCategories(code: string): Intl.LDMLPluralRule[] {
3840
return ['one', 'other'];
3941
}
4042

43+
// TODO: Sort won't be needed once https://github.com/tc39/ecma402/pull/918
44+
// is adopted in all environments (e.g. Node.js 24 & later).
4145
const pr = new Intl.PluralRules(code);
42-
return pr.resolvedOptions().pluralCategories;
46+
const pc = pr.resolvedOptions().pluralCategories;
47+
pc.sort((a, b) =>
48+
CLDR_PLURALS.indexOf(a) < CLDR_PLURALS.indexOf(b) ? -1 : 1,
49+
);
50+
return pc;
4351
}

0 commit comments

Comments
 (0)