Visitar URL original
feat(@formatjs/intl-pluralrules): add supported locales check to shou… · formatjs/formatjs@395efcb · GitHub
Skip to content

Commit 395efcb

Browse files
committed
feat(@formatjs/intl-pluralrules): add supported locales check to should-polyfill, fix #3066
1 parent cf7c48f commit 395efcb

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
export function shouldPolyfill() {
1+
function supportedLocalesOf(locale?: string | string[]) {
2+
if (!locale) {
3+
return true
4+
}
5+
const locales = Array.isArray(locale) ? locale : [locale]
6+
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length
7+
}
8+
9+
export function shouldPolyfill(locale?: string | string[]) {
210
return (
311
!('PluralRules' in Intl) ||
412
new Intl.PluralRules('en', {minimumFractionDigits: 2} as any).select(1) ===
5-
'one'
13+
'one' ||
14+
!supportedLocalesOf(locale)
615
)
716
}

0 commit comments

Comments
 (0)