MCPcopy Create free account
hub / github.com/messageformat/messageformat / normalize

Function normalize

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

Source from the content-addressed store, hash-verified

4import { identifier } from 'safe-identifier';
5
6function normalize(locale) {
7 if (typeof locale !== 'string' || locale.length < 2)
8 throw new RangeError(`Invalid language tag: ${locale}`);
9
10 // The only locale for which anything but the primary subtag matters is
11 // Portuguese as spoken in Portugal.
12 if (locale.startsWith('pt-PT')) return 'pt-PT';
13
14 const m = locale.match(/.+?(?=[-_])/);
15 return m ? m[0] : locale;
16}
17
18export function getPlural(locale) {
19 if (typeof locale === 'function') {

Callers 2

getPluralFunction · 0.85
hasPluralFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…