| 4 | import { identifier } from 'safe-identifier'; |
| 5 | |
| 6 | function 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 | |
| 18 | export function getPlural(locale) { |
| 19 | if (typeof locale === 'function') { |