File tree Expand file tree Collapse file tree
translate/src/utils/message Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { CLDR_PLURALS } from '../constants' ;
2+
13export 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}
You can’t perform that action at this time.
0 commit comments