File tree 2 files changed +15
-1
lines changed
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';
16
16
17
17
// need Intl polyfill, Intl not supported in Safari
18
18
import 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
+ }
20
33
21
34
// use this to allow nested messages, taken from docs:
22
35
// https://github.com/yahoo/react-intl/wiki/Upgrade-Guide#flatten-messages-object
Original file line number Diff line number Diff line change 38
38
"cuid" : " ^1.3.8" ,
39
39
"express" : " ^4.13.4" ,
40
40
"intl" : " ^1.2.4" ,
41
+ "intl-locales-supported" : " ^1.0.0" ,
41
42
"isomorphic-fetch" : " ^2.2.1" ,
42
43
"limax" : " ^1.3.0" ,
43
44
"mongoose" : " ^4.4.20" ,
You can’t perform that action at this time.
0 commit comments