File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,20 @@ import { addLocaleData } from 'react-intl';
1616
1717// need Intl polyfill, Intl not supported in Safari
1818import Intl from 'intl' ;
19- global . Intl = Intl ;
19+ import areIntlLocalesSupported from 'intl-locales-supported' ;
20+
21+ if ( global . Intl ) {
22+ // Determine if the built-in `Intl` has the locale data we need.
23+ if ( ! areIntlLocalesSupported ( enabledLanguages ) ) {
24+ // `Intl` exists, but it doesn't have the data we need, so load the
25+ // polyfill and patch the constructors we need with the polyfill's.
26+ global . Intl . NumberFormat = Intl . NumberFormat ;
27+ global . Intl . DateTimeFormat = Intl . DateTimeFormat ;
28+ }
29+ } else {
30+ // No `Intl`, so use and load the polyfill.
31+ global . Intl = Intl ;
32+ }
2033
2134// use this to allow nested messages, taken from docs:
2235// https://github.com/yahoo/react-intl/wiki/Upgrade-Guide#flatten-messages-object
Original file line number Diff line number Diff line change 3838 "cuid" : " ^1.3.8" ,
3939 "express" : " ^4.13.4" ,
4040 "intl" : " ^1.2.4" ,
41+ "intl-locales-supported" : " ^1.0.0" ,
4142 "isomorphic-fetch" : " ^2.2.1" ,
4243 "limax" : " ^1.3.0" ,
4344 "mongoose" : " ^4.4.20" ,
You can’t perform that action at this time.
0 commit comments