Skip to content

Commit

Permalink
feat(@formatjs/intl-relativetimeformat): Use native
Browse files Browse the repository at this point in the history
Intl.getCanonicalLocales
BREAKING CHANGE: This requires @formatjs/intl-getcanonicallocales for
IE11 and below
  • Loading branch information
longlho committed May 23, 2020
1 parent 54cea38 commit c4b719c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/intl-relativetimeformat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@formatjs/intl-pluralrules": "^1.5.9",
"@types/jest": "^25.2.1",
"formatjs-extract-cldr-data": "^10.1.8",
"@formatjs/intl-getcanonicallocales": "1.1.1",
"ts-jest": "^25.4.0"
},
"dependencies": {
Expand Down
9 changes: 6 additions & 3 deletions packages/intl-relativetimeformat/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
getLocaleHierarchy,
supportedLocales,
RelativeTimeLocaleData,
getCanonicalLocales,
createResolveLocale,
UnpackedLocaleFieldsData,
setInternalSlot,
Expand All @@ -18,6 +17,7 @@ import {
isLiteralPart,
LiteralPart,
} from '@formatjs/intl-utils';
import type {getCanonicalLocales} from '@formatjs/intl-getcanonicallocales';

export interface IntlRelativeTimeFormatOptions {
/**
Expand Down Expand Up @@ -282,7 +282,8 @@ export default class RelativeTimeFormat {
'initializedRelativeTimeFormat',
true
);
const requestedLocales = getCanonicalLocales(locales);
const requestedLocales = ((Intl as any)
.getCanonicalLocales as typeof getCanonicalLocales)(locales);
const opt: any = Object.create(null);
const opts =
options === undefined ? Object.create(null) : toObject(options);
Expand Down Expand Up @@ -446,7 +447,9 @@ export default class RelativeTimeFormat {
) {
return supportedLocales(
RelativeTimeFormat.availableLocales,
getCanonicalLocales(locales),
((Intl as any).getCanonicalLocales as typeof getCanonicalLocales)(
locales
),
options
);
}
Expand Down

0 comments on commit c4b719c

Please sign in to comment.