MCPcopy Index your code
hub / github.com/messageformat/messageformat / getPlural

Function getPlural

packages/messageformat/src/plurals.js:18–45  ·  view source on GitHub ↗
(locale)

Source from the content-addressed store, hash-verified

16}
17
18export function getPlural(locale) {
19 if (typeof locale === 'function') {
20 const lc = normalize(locale.name);
21 return {
22 isDefault: false,
23 id: identifier(lc),
24 lc,
25 locale: locale.name,
26 getPlural: locale,
27 cardinals: locale.cardinals || [],
28 ordinals: locale.ordinals || []
29 };
30 }
31 const lc = normalize(locale);
32 if (lc in Plurals) {
33 return {
34 isDefault: true,
35 id: identifier(lc),
36 lc,
37 locale,
38 getCardinal: Cardinals[lc],
39 getPlural: Plurals[lc],
40 cardinals: PluralCategories[lc].cardinal,
41 ordinals: PluralCategories[lc].ordinal
42 };
43 }
44 return null;
45}
46
47export function getAllPlurals(firstLocale) {
48 const keys = Object.keys(Plurals).filter(key => key !== firstLocale);

Callers 2

constructorMethod · 0.90
setLocaleMethod · 0.85

Calls 1

normalizeFunction · 0.85

Tested by

no test coverage detected