gt-react-native 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/lib/commonjs/plugin-dir/index.js +4 -4
  2. package/lib/commonjs/plugin-dir/index.js.map +1 -1
  3. package/lib/commonjs/plugin-dir/types.js +9 -0
  4. package/lib/commonjs/plugin-dir/types.js.map +1 -1
  5. package/lib/commonjs/tools/testLocalePolyfill.js +125 -11
  6. package/lib/commonjs/tools/testLocalePolyfill.js.map +1 -1
  7. package/lib/module/plugin-dir/index.js +4 -4
  8. package/lib/module/plugin-dir/index.js.map +1 -1
  9. package/lib/module/plugin-dir/types.js +5 -0
  10. package/lib/module/plugin-dir/types.js.map +1 -1
  11. package/lib/module/tools/testLocalePolyfill.js +125 -11
  12. package/lib/module/tools/testLocalePolyfill.js.map +1 -1
  13. package/lib/typescript/commonjs/src/plugin-dir/index.d.ts +2 -2
  14. package/lib/typescript/commonjs/src/plugin-dir/index.d.ts.map +1 -1
  15. package/lib/typescript/commonjs/src/plugin-dir/types.d.ts +3 -0
  16. package/lib/typescript/commonjs/src/plugin-dir/types.d.ts.map +1 -1
  17. package/lib/typescript/commonjs/src/tools/testLocalePolyfill.d.ts +2 -6
  18. package/lib/typescript/commonjs/src/tools/testLocalePolyfill.d.ts.map +1 -1
  19. package/lib/typescript/module/src/plugin-dir/index.d.ts +2 -2
  20. package/lib/typescript/module/src/plugin-dir/index.d.ts.map +1 -1
  21. package/lib/typescript/module/src/plugin-dir/types.d.ts +3 -0
  22. package/lib/typescript/module/src/plugin-dir/types.d.ts.map +1 -1
  23. package/lib/typescript/module/src/tools/testLocalePolyfill.d.ts +2 -6
  24. package/lib/typescript/module/src/tools/testLocalePolyfill.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/plugin-dir/index.ts +6 -16
  27. package/src/plugin-dir/types.ts +23 -0
  28. package/src/tools/testLocalePolyfill.ts +170 -15
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = _default;
7
7
  var path = _interopRequireWildcard(require("path"));
8
+ var _types = require("./types");
8
9
  var _resolveLocales = require("./utils/resolveLocales");
9
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
11
  function _default(babel, {
11
12
  locales,
12
13
  config,
13
14
  configFilePath,
14
- entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx')
15
+ entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx'),
16
+ excludePolyfills = []
15
17
  }) {
16
18
  const {
17
19
  types: t
@@ -33,9 +35,7 @@ function _default(babel, {
33
35
  });
34
36
 
35
37
  // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
36
- const imports = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
37
- // https://github.com/formatjs/formatjs/issues/4463
38
- '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz', ...resolvedLocales.flatMap(locale => [`@formatjs/intl-displaynames/locale-data/${locale}`, `@formatjs/intl-listformat/locale-data/${locale}`, `@formatjs/intl-pluralrules/locale-data/${locale}`, `@formatjs/intl-numberformat/locale-data/${locale}`, `@formatjs/intl-relativetimeformat/locale-data/${locale}`, `@formatjs/intl-datetimeformat/locale-data/${locale}`])];
38
+ const imports = [..._types.POLYFILLS.filter(polyfill => !excludePolyfills.includes(polyfill)), ...resolvedLocales.flatMap(locale => [..._types.LOCALE_POLYFILLS.map(localeData => `${localeData}/${locale}`)])];
39
39
  const existingImports = new Set();
40
40
  programPath.node.body.forEach(node => {
41
41
  if (t.isImportDeclaration(node) && typeof node.source.value === 'string' && imports.includes(node.source.value)) {
@@ -1 +1 @@
1
- {"version":3,"names":["path","_interopRequireWildcard","require","_resolveLocales","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","types","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","resolveLocales","imports","flatMap","locale","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","includes","add","importsToAdd","filter","imp","length","newImports","map","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AAAwD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA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,2CAA2C;QAAE;QAC7C,sCAAsC,EACtC,4CAA4C,EAC5C,wCAAwC,EACxC,0CAA0C,EAC1C,GAAGF,eAAe,CAACG,OAAO,CAAEC,MAAM,IAAK,CACrC,2CAA2CA,MAAM,EAAE,EACnD,yCAAyCA,MAAM,EAAE,EACjD,0CAA0CA,MAAM,EAAE,EAClD,2CAA2CA,MAAM,EAAE,EACnD,iDAAiDA,MAAM,EAAE,EACzD,6CAA6CA,MAAM,EAAE,CACtD,CAAC,CACH;QAED,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAS,CAAC;QACzCZ,WAAW,CAACa,IAAI,CAACC,IAAI,CAACC,OAAO,CAAEF,IAAI,IAAK;UACtC,IACE5C,CAAC,CAAC+C,mBAAmB,CAACH,IAAI,CAAC,IAC3B,OAAOA,IAAI,CAACI,MAAM,CAACC,KAAK,KAAK,QAAQ,IACrCV,OAAO,CAACW,QAAQ,CAACN,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC,EACnC;YACAP,eAAe,CAACS,GAAG,CAACP,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC;UACxC;QACF,CAAC,CAAC;QAEF,MAAMG,YAAY,GAAGb,OAAO,CAACc,MAAM,CAAEC,GAAG,IAAK,CAACZ,eAAe,CAAChC,GAAG,CAAC4C,GAAG,CAAC,CAAC;QAEvE,IAAIF,YAAY,CAACG,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGJ,YAAY,CAACK,GAAG,CAAEC,UAAU,IAC7C1D,CAAC,CAAC2D,iBAAiB,CAAC,EAAE,EAAE3D,CAAC,CAAC4D,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED3B,WAAW,CAACa,IAAI,CAACC,IAAI,CAACgB,OAAO,CAAC,GAAGL,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["path","_interopRequireWildcard","require","_types","_resolveLocales","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","excludePolyfills","types","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","resolveLocales","imports","POLYFILLS","filter","polyfill","includes","flatMap","locale","LOCALE_POLYFILLS","map","localeData","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","add","importsToAdd","imp","length","newImports","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAwD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM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CAACoB,IAAI,CAACC,IAAI,CAACC,OAAO,CAAEF,IAAI,IAAK;UACtC,IACEpD,CAAC,CAACuD,mBAAmB,CAACH,IAAI,CAAC,IAC3B,OAAOA,IAAI,CAACI,MAAM,CAACC,KAAK,KAAK,QAAQ,IACrCjB,OAAO,CAACI,QAAQ,CAACQ,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC,EACnC;YACAP,eAAe,CAACQ,GAAG,CAACN,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC;UACxC;QACF,CAAC,CAAC;QAEF,MAAME,YAAY,GAAGnB,OAAO,CAACE,MAAM,CAAEkB,GAAG,IAAK,CAACV,eAAe,CAACxC,GAAG,CAACkD,GAAG,CAAC,CAAC;QAEvE,IAAID,YAAY,CAACE,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGH,YAAY,CAACX,GAAG,CAAEe,UAAU,IAC7C/D,CAAC,CAACgE,iBAAiB,CAAC,EAAE,EAAEhE,CAAC,CAACiE,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED/B,WAAW,CAACoB,IAAI,CAACC,IAAI,CAACa,OAAO,CAAC,GAAGJ,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.POLYFILLS = exports.LOCALE_POLYFILLS = void 0;
7
+ const POLYFILLS = exports.POLYFILLS = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
8
+ // https://github.com/formatjs/formatjs/issues/4463
9
+ '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz'];
10
+ const LOCALE_POLYFILLS = exports.LOCALE_POLYFILLS = [`@formatjs/intl-displaynames/locale-data`, `@formatjs/intl-listformat/locale-data`, `@formatjs/intl-pluralrules/locale-data`, `@formatjs/intl-numberformat/locale-data`, `@formatjs/intl-relativetimeformat/locale-data`, `@formatjs/intl-datetimeformat/locale-data`];
2
11
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":["POLYFILLS","exports","LOCALE_POLYFILLS"],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,CACvB,6CAA6C,EAC7C,gCAAgC,EAChC,sCAAsC,EACtC,oCAAoC,EACpC,2CAA2C;AAAE;AAC7C,sCAAsC,EACtC,4CAA4C,EAC5C,wCAAwC,EACxC,0CAA0C,CAClC;AAEH,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAC9B,yCAAyC,EACzC,uCAAuC,EACvC,wCAAwC,EACxC,yCAAyC,EACzC,+CAA+C,EAC/C,2CAA2C,CACnC","ignoreList":[]}
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.testLocalePolyfill = testLocalePolyfill;
7
- function testLocalePolyfill(locale = 'en-US') {
7
+ var _internal = require("generaltranslation/internal");
8
+ function testLocalePolyfill(locale = _internal.libraryDefaultLocale) {
8
9
  const problems = [];
9
10
 
10
11
  // 1. basic presence
@@ -16,10 +17,48 @@ function testLocalePolyfill(locale = 'en-US') {
16
17
  });
17
18
 
18
19
  // 2. locale actually supported (no silent fallback)
19
- const dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
20
- const nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
20
+ let dtfSupported = false;
21
+ try {
22
+ dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
23
+ } catch (e) {
24
+ problems.push(`DateTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
25
+ }
26
+ let nfSupported = false;
27
+ try {
28
+ nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
29
+ } catch (e) {
30
+ problems.push(`NumberFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
31
+ }
32
+ let prSupported = false;
33
+ try {
34
+ prSupported = Intl.PluralRules.supportedLocalesOf([locale])[0] === locale;
35
+ } catch (e) {
36
+ problems.push(`PluralRules.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
37
+ }
38
+ let rtfSupported = false;
39
+ try {
40
+ rtfSupported = Intl.RelativeTimeFormat.supportedLocalesOf([locale])[0] === locale;
41
+ } catch (e) {
42
+ problems.push(`RelativeTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
43
+ }
44
+ let lfSupported = false;
45
+ try {
46
+ lfSupported = Intl.ListFormat.supportedLocalesOf([locale])[0] === locale;
47
+ } catch (e) {
48
+ problems.push(`ListFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
49
+ }
50
+ let dnSupported = false;
51
+ try {
52
+ dnSupported = Intl.DisplayNames.supportedLocalesOf([locale])[0] === locale;
53
+ } catch (e) {
54
+ problems.push(`DisplayNames.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
55
+ }
21
56
  if (!dtfSupported) problems.push(`${locale} not supported by DateTimeFormat`);
22
57
  if (!nfSupported) problems.push(`${locale} not supported by NumberFormat`);
58
+ if (!prSupported) problems.push(`${locale} not supported by PluralRules`);
59
+ if (!rtfSupported) problems.push(`${locale} not supported by RelativeTimeFormat`);
60
+ if (!lfSupported) problems.push(`${locale} not supported by ListFormat`);
61
+ if (!dnSupported) problems.push(`${locale} not supported by DisplayNames`);
23
62
 
24
63
  // 3. numeric separators sanity
25
64
  let group, decimal;
@@ -41,16 +80,91 @@ function testLocalePolyfill(locale = 'en-US') {
41
80
  problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
42
81
  }
43
82
 
44
- // 5. show example formatted values
45
- const example = {
46
- number: new Intl.NumberFormat(locale).format(1234.5),
47
- date: new Intl.DateTimeFormat(locale, {
83
+ // 5. relative time format sanity
84
+ try {
85
+ const rtf = new Intl.RelativeTimeFormat(locale);
86
+ const sample = rtf.format(-1, 'day');
87
+ if (!sample) problems.push('RelativeTimeFormat returned undefined');
88
+ } catch (e) {
89
+ problems.push(`RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`);
90
+ }
91
+
92
+ // 6. list format sanity
93
+ try {
94
+ const lf = new Intl.ListFormat(locale);
95
+ const sample = lf.format(['apple', 'orange', 'banana']);
96
+ if (!sample) problems.push('ListFormat returned undefined');
97
+ } catch (e) {
98
+ problems.push(`ListFormat threw: ${e instanceof Error ? e.message : String(e)}`);
99
+ }
100
+
101
+ // 7. display names sanity
102
+ try {
103
+ const dn = new Intl.DisplayNames(locale, {
104
+ type: 'language'
105
+ });
106
+ const sample = dn.of('en');
107
+ if (!sample) problems.push('DisplayNames returned undefined');
108
+ } catch (e) {
109
+ problems.push(`DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`);
110
+ }
111
+
112
+ // 8. locale sanity
113
+ try {
114
+ const loc = new Intl.Locale(locale);
115
+ if (!loc.language) problems.push('Locale missing language property');
116
+ } catch (e) {
117
+ problems.push(`Locale threw: ${e instanceof Error ? e.message : String(e)}`);
118
+ }
119
+
120
+ // 9. show example formatted values
121
+ const example = {};
122
+ try {
123
+ example.number = new Intl.NumberFormat(locale).format(1234.5);
124
+ } catch (e) {
125
+ example.number = 'ERROR';
126
+ }
127
+ try {
128
+ example.date = new Intl.DateTimeFormat(locale, {
48
129
  dateStyle: 'long'
49
- }).format(new Date('2020-01-02')),
50
- weekday: new Intl.DateTimeFormat(locale, {
130
+ }).format(new Date('2020-01-02'));
131
+ } catch (e) {
132
+ example.date = 'ERROR';
133
+ }
134
+ try {
135
+ example.weekday = new Intl.DateTimeFormat(locale, {
51
136
  weekday: 'long'
52
- }).format(new Date('2020-01-02'))
53
- };
137
+ }).format(new Date('2020-01-02'));
138
+ } catch (e) {
139
+ example.weekday = 'ERROR';
140
+ }
141
+ try {
142
+ example.pluralRule = new Intl.PluralRules(locale).select(5);
143
+ } catch (e) {
144
+ example.pluralRule = 'ERROR';
145
+ }
146
+ try {
147
+ example.relativeTime = new Intl.RelativeTimeFormat(locale).format(-1, 'day');
148
+ } catch (e) {
149
+ example.relativeTime = 'ERROR';
150
+ }
151
+ try {
152
+ example.list = new Intl.ListFormat(locale).format(['apple', 'orange', 'banana']);
153
+ } catch (e) {
154
+ example.list = 'ERROR';
155
+ }
156
+ try {
157
+ example.displayName = new Intl.DisplayNames(locale, {
158
+ type: 'language'
159
+ }).of('en') || 'UNDEFINED';
160
+ } catch (e) {
161
+ example.displayName = 'ERROR';
162
+ }
163
+ try {
164
+ example.locale = new Intl.Locale(locale).language;
165
+ } catch (e) {
166
+ example.locale = 'ERROR';
167
+ }
54
168
  const result = {
55
169
  ok: problems.length === 0,
56
170
  problems,
@@ -1 +1 @@
1
- {"version":3,"names":["testLocalePolyfill","locale","problems","global","Intl","push","apis","forEach","a","dtfSupported","DateTimeFormat","supportedLocalesOf","nfSupported","NumberFormat","group","decimal","parts","formatToParts","find","p","type","value","e","Error","message","String","pr","PluralRules","sample","select","example","number","format","date","dateStyle","Date","weekday","result","ok","length","console","log","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":";;;;;;AAAO,SAASA,kBAAkBA,CAACC,MAAM,GAAG,OAAO,EAAE;EACnD,MAAMC,QAAQ,GAAG,EAAE;;EAEnB;EACA,IAAI,CAACC,MAAM,CAACC,IAAI,EAAEF,QAAQ,CAACG,IAAI,CAAC,uBAAuB,CAAC;EACxD,MAAMC,IAAI,GAAG,CACX,QAAQ,EACR,cAAc,E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R4B,OACF,CAAC;EACH;EACA,OAAOO,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["_internal","require","testLocalePolyfill","locale","libraryDefaultLocale","problems","global","Intl","push","apis","forEach","a","dtfSupported","DateTimeFormat","supportedLocalesOf","e","Error","message","String","nfSupported","NumberFormat","prSupported","PluralRules","rtfSupported","RelativeTimeFormat","lfSupported","ListFormat","dnSupported","DisplayNames","group","decimal","parts","formatToParts","find","p","type","value","pr","sample","select","rtf","format","lf","dn","of","loc","Locale","language","example","number","date","dateStyle","Date","weekday","pluralRule","relativeTime","list","displayName","result","ok","length","console","log","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAACC,MAAM,GAAGC,8BAAoB,EAAE;EAChE,MAAMC,QAAQ,GAAG,EAAE;;EAEnB;EACA,IAAI,CAACC,MAAM,CAACC,IAAI,EAAEF,QAAQ,CAACG,IAAI,CAAC,uBAAuB,CAAC;EACxD,MAAMC,IAAI,GAAG,CACX,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,cAAc,CACf;EACDA,IAAI,CAACC,OAAO,CAAEC,CAAC,IAAK;IAClB;IACA,IAAI,CAACJ,IAAI,CAACI,CAAC,CAAC,EAAEN,QAAQ,CAACG,IAAI,CAAC,QAAQG,CAAC,UAAU,CAAC;EAClD,CAAC,CAAC;;EAEF;EACA,IAAIC,YAAY,GAAG,KAAK;EACxB,IAAI;IACFA,YAAY,GACVL,IAAI,CAACM,cAAc,CAACC,kBAAkB,CAAC,CAACX,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAKA,MAAM;EAClE,CAAC,CAAC,OAAOY,CAAC,EAAE;IACVV,QAAQ,CAACG,IAAI,CACX,4CAA4CO,CAAC,YAAYC,KAAK,GAAGD,CAAC,CAACE,OAAO,GAAGC,MAAM,CAACH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C,CAChD,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAC;EACJ,CAAC,CAAC,OAAO1B,CAAC,EAAE;IACViC,OAAO,CAACQ,IAAI,GAAG,OAAO;EACxB;EAEA,IAAI;IACFR,OAAO,CAACS,WAAW,GACjB,IAAIlD,IAAI,CAACqB,YAAY,CAACzB,MAAM,EAAE;MAAEgC,IAAI,EAAE;IAAW,CAAC,CAAC,CAACS,EAAE,CAAC,IAAI,CAAC,IAC5D,WAAW;EACf,CAAC,CAAC,OAAO7B,CAAC,EAAE;IACViC,OAAO,CAACS,WAAW,GAAG,OAAO;EAC/B;EAEA,IAAI;IACFT,OAAO,CAAC7C,MAAM,GAAG,IAAII,IAAI,CAACuC,MAAM,CAAC3C,MAAM,CAAC,CAAC4C,QAAQ;EACnD,CAAC,CAAC,OAAOhC,CAAC,EAAE;IACViC,OAAO,CAAC7C,MAAM,GAAG,OAAO;EAC1B;EAEA,MAAMuD,MAAM,GAAG;IACbC,EAAE,EAAEtD,QAAQ,CAACuD,MAAM,KAAK,CAAC;IACzBvD,QAAQ;IACRwB,KAAK;IACLC,OAAO;IACPkB;EACF,CAAC;EAED,IAAIU,MAAM,CAACC,EAAE,EAAE;IACbE,OAAO,CAACC,GAAG,CAAC,kCAAkC3D,MAAM,EAAE,EAAE6C,OAAO,CAAC;EAClE,CAAC,MAAM;IACLa,OAAO,CAACE,IAAI,CACV,sCAAsC5D,MAAM,GAAG,EAC/CE,QAAQ,EACR2C,OACF,CAAC;EACH;EACA,OAAOU,MAAM;AACf","ignoreList":[]}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  import * as path from 'path';
4
+ import { LOCALE_POLYFILLS, POLYFILLS } from "./types.js";
4
5
  import { resolveLocales } from "./utils/resolveLocales.js";
5
6
  export default function (babel, {
6
7
  locales,
7
8
  config,
8
9
  configFilePath,
9
- entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx')
10
+ entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx'),
11
+ excludePolyfills = []
10
12
  }) {
11
13
  const {
12
14
  types: t
@@ -28,9 +30,7 @@ export default function (babel, {
28
30
  });
29
31
 
30
32
  // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
31
- const imports = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
32
- // https://github.com/formatjs/formatjs/issues/4463
33
- '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz', ...resolvedLocales.flatMap(locale => [`@formatjs/intl-displaynames/locale-data/${locale}`, `@formatjs/intl-listformat/locale-data/${locale}`, `@formatjs/intl-pluralrules/locale-data/${locale}`, `@formatjs/intl-numberformat/locale-data/${locale}`, `@formatjs/intl-relativetimeformat/locale-data/${locale}`, `@formatjs/intl-datetimeformat/locale-data/${locale}`])];
33
+ const imports = [...POLYFILLS.filter(polyfill => !excludePolyfills.includes(polyfill)), ...resolvedLocales.flatMap(locale => [...LOCALE_POLYFILLS.map(localeData => `${localeData}/${locale}`)])];
34
34
  const existingImports = new Set();
35
35
  programPath.node.body.forEach(node => {
36
36
  if (t.isImportDeclaration(node) && typeof node.source.value === 'string' && imports.includes(node.source.value)) {
@@ -1 +1 @@
1
- {"version":3,"names":["path","resolveLocales","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","types","t","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","imports","flatMap","locale","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","includes","add","importsToAdd","filter","imp","has","length","newImports","map","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;AAAA,OAAO,KAAKA,IAAI,MAAM,MAAM;AAG5B,SAASC,cAAc,Q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OAAOA,IAAI,CAACI,MAAM,CAACC,KAAK,KAAK,QAAQ,IACrCV,OAAO,CAACW,QAAQ,CAACN,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC,EACnC;YACAP,eAAe,CAACS,GAAG,CAACP,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC;UACxC;QACF,CAAC,CAAC;QAEF,MAAMG,YAAY,GAAGb,OAAO,CAACc,MAAM,CAAEC,GAAG,IAAK,CAACZ,eAAe,CAACa,GAAG,CAACD,GAAG,CAAC,CAAC;QAEvE,IAAIF,YAAY,CAACI,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGL,YAAY,CAACM,GAAG,CAAEC,UAAU,IAC7C/B,CAAC,CAACgC,iBAAiB,CAAC,EAAE,EAAEhC,CAAC,CAACiC,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED3B,WAAW,CAACY,IAAI,CAACC,IAAI,CAACiB,OAAO,CAAC,GAAGL,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["path","LOCALE_POLYFILLS","POLYFILLS","resolveLocales","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","excludePolyfills","types","t","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","imports","filter","polyfill","includes","flatMap","locale","map","localeData","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","add","importsToAdd","imp","has","length","newImports","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;AAAA,OAAO,KAAKA,IAAI,MAAM,MAAM;AAE5B,SAASC,gBAAgB,EAAEC,SAAS,QAA4B,YAAS;AACzE,SAASC,cAAc,QAAQ,2BAAwB;AAEvD,eAAe,UACbC,KAA8B,EAC9B;EACEC,OAAO;EACPC,MAAM;EACNC,cAAc;EACdC,kBAAkB,GAAGR,IAAI,CAACS,OAAO,CAACC,OAAO,CAACC,GAAG,C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ME,YAAY,GAAGjB,OAAO,CAACC,MAAM,CAAEiB,GAAG,IAAK,CAACV,eAAe,CAACW,GAAG,CAACD,GAAG,CAAC,CAAC;QAEvE,IAAID,YAAY,CAACG,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGJ,YAAY,CAACX,GAAG,CAAEgB,UAAU,IAC7CjC,CAAC,CAACkC,iBAAiB,CAAC,EAAE,EAAElC,CAAC,CAACmC,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED7B,WAAW,CAACiB,IAAI,CAACC,IAAI,CAACc,OAAO,CAAC,GAAGJ,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
+
3
+ export const POLYFILLS = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
4
+ // https://github.com/formatjs/formatjs/issues/4463
5
+ '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz'];
6
+ export const LOCALE_POLYFILLS = [`@formatjs/intl-displaynames/locale-data`, `@formatjs/intl-listformat/locale-data`, `@formatjs/intl-pluralrules/locale-data`, `@formatjs/intl-numberformat/locale-data`, `@formatjs/intl-relativetimeformat/locale-data`, `@formatjs/intl-datetimeformat/locale-data`];
2
7
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":["POLYFILLS","LOCALE_POLYFILLS"],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":";;AAAA,OAAO,MAAMA,SAAS,GAAG,CACvB,6CAA6C,EAC7C,gCAAgC,EAChC,sCAAsC,EACtC,oCAAoC,EACpC,2CAA2C;AAAE;AAC7C,sCAAsC,EACtC,4CAA4C,EAC5C,wCAAwC,EACxC,0CAA0C,CAClC;AAEV,OAAO,MAAMC,gBAAgB,GAAG,CAC9B,yCAAyC,EACzC,uCAAuC,EACvC,wCAAwC,EACxC,yCAAyC,EACzC,+CAA+C,EAC/C,2CAA2C,CACnC","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
- export function testLocalePolyfill(locale = 'en-US') {
3
+ import { libraryDefaultLocale } from 'generaltranslation/internal';
4
+ export function testLocalePolyfill(locale = libraryDefaultLocale) {
4
5
  const problems = [];
5
6
 
6
7
  // 1. basic presence
@@ -12,10 +13,48 @@ export function testLocalePolyfill(locale = 'en-US') {
12
13
  });
13
14
 
14
15
  // 2. locale actually supported (no silent fallback)
15
- const dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
16
- const nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
16
+ let dtfSupported = false;
17
+ try {
18
+ dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
19
+ } catch (e) {
20
+ problems.push(`DateTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
21
+ }
22
+ let nfSupported = false;
23
+ try {
24
+ nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
25
+ } catch (e) {
26
+ problems.push(`NumberFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
27
+ }
28
+ let prSupported = false;
29
+ try {
30
+ prSupported = Intl.PluralRules.supportedLocalesOf([locale])[0] === locale;
31
+ } catch (e) {
32
+ problems.push(`PluralRules.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
33
+ }
34
+ let rtfSupported = false;
35
+ try {
36
+ rtfSupported = Intl.RelativeTimeFormat.supportedLocalesOf([locale])[0] === locale;
37
+ } catch (e) {
38
+ problems.push(`RelativeTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
39
+ }
40
+ let lfSupported = false;
41
+ try {
42
+ lfSupported = Intl.ListFormat.supportedLocalesOf([locale])[0] === locale;
43
+ } catch (e) {
44
+ problems.push(`ListFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
45
+ }
46
+ let dnSupported = false;
47
+ try {
48
+ dnSupported = Intl.DisplayNames.supportedLocalesOf([locale])[0] === locale;
49
+ } catch (e) {
50
+ problems.push(`DisplayNames.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
51
+ }
17
52
  if (!dtfSupported) problems.push(`${locale} not supported by DateTimeFormat`);
18
53
  if (!nfSupported) problems.push(`${locale} not supported by NumberFormat`);
54
+ if (!prSupported) problems.push(`${locale} not supported by PluralRules`);
55
+ if (!rtfSupported) problems.push(`${locale} not supported by RelativeTimeFormat`);
56
+ if (!lfSupported) problems.push(`${locale} not supported by ListFormat`);
57
+ if (!dnSupported) problems.push(`${locale} not supported by DisplayNames`);
19
58
 
20
59
  // 3. numeric separators sanity
21
60
  let group, decimal;
@@ -37,16 +76,91 @@ export function testLocalePolyfill(locale = 'en-US') {
37
76
  problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
38
77
  }
39
78
 
40
- // 5. show example formatted values
41
- const example = {
42
- number: new Intl.NumberFormat(locale).format(1234.5),
43
- date: new Intl.DateTimeFormat(locale, {
79
+ // 5. relative time format sanity
80
+ try {
81
+ const rtf = new Intl.RelativeTimeFormat(locale);
82
+ const sample = rtf.format(-1, 'day');
83
+ if (!sample) problems.push('RelativeTimeFormat returned undefined');
84
+ } catch (e) {
85
+ problems.push(`RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`);
86
+ }
87
+
88
+ // 6. list format sanity
89
+ try {
90
+ const lf = new Intl.ListFormat(locale);
91
+ const sample = lf.format(['apple', 'orange', 'banana']);
92
+ if (!sample) problems.push('ListFormat returned undefined');
93
+ } catch (e) {
94
+ problems.push(`ListFormat threw: ${e instanceof Error ? e.message : String(e)}`);
95
+ }
96
+
97
+ // 7. display names sanity
98
+ try {
99
+ const dn = new Intl.DisplayNames(locale, {
100
+ type: 'language'
101
+ });
102
+ const sample = dn.of('en');
103
+ if (!sample) problems.push('DisplayNames returned undefined');
104
+ } catch (e) {
105
+ problems.push(`DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`);
106
+ }
107
+
108
+ // 8. locale sanity
109
+ try {
110
+ const loc = new Intl.Locale(locale);
111
+ if (!loc.language) problems.push('Locale missing language property');
112
+ } catch (e) {
113
+ problems.push(`Locale threw: ${e instanceof Error ? e.message : String(e)}`);
114
+ }
115
+
116
+ // 9. show example formatted values
117
+ const example = {};
118
+ try {
119
+ example.number = new Intl.NumberFormat(locale).format(1234.5);
120
+ } catch (e) {
121
+ example.number = 'ERROR';
122
+ }
123
+ try {
124
+ example.date = new Intl.DateTimeFormat(locale, {
44
125
  dateStyle: 'long'
45
- }).format(new Date('2020-01-02')),
46
- weekday: new Intl.DateTimeFormat(locale, {
126
+ }).format(new Date('2020-01-02'));
127
+ } catch (e) {
128
+ example.date = 'ERROR';
129
+ }
130
+ try {
131
+ example.weekday = new Intl.DateTimeFormat(locale, {
47
132
  weekday: 'long'
48
- }).format(new Date('2020-01-02'))
49
- };
133
+ }).format(new Date('2020-01-02'));
134
+ } catch (e) {
135
+ example.weekday = 'ERROR';
136
+ }
137
+ try {
138
+ example.pluralRule = new Intl.PluralRules(locale).select(5);
139
+ } catch (e) {
140
+ example.pluralRule = 'ERROR';
141
+ }
142
+ try {
143
+ example.relativeTime = new Intl.RelativeTimeFormat(locale).format(-1, 'day');
144
+ } catch (e) {
145
+ example.relativeTime = 'ERROR';
146
+ }
147
+ try {
148
+ example.list = new Intl.ListFormat(locale).format(['apple', 'orange', 'banana']);
149
+ } catch (e) {
150
+ example.list = 'ERROR';
151
+ }
152
+ try {
153
+ example.displayName = new Intl.DisplayNames(locale, {
154
+ type: 'language'
155
+ }).of('en') || 'UNDEFINED';
156
+ } catch (e) {
157
+ example.displayName = 'ERROR';
158
+ }
159
+ try {
160
+ example.locale = new Intl.Locale(locale).language;
161
+ } catch (e) {
162
+ example.locale = 'ERROR';
163
+ }
50
164
  const result = {
51
165
  ok: problems.length === 0,
52
166
  problems,
@@ -1 +1 @@
1
- {"version":3,"names":["testLocalePolyfill","locale","problems","global","Intl","push","apis","forEach","a","dtfSupported","DateTimeFormat","supportedLocalesOf","nfSupported","NumberFormat","group","decimal","parts","formatToParts","find","p","type","value","e","Error","message","String","pr","PluralRules","sample","select","example","number","format","date","dateStyle","Date","weekday","result","ok","length","console","log","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":";;AAAA,OAAO,SAASA,kBAAkBA,CAACC,MAAM,GAAG,OAAO,EAAE;EACnD,MAAMC,QAAQ,GAAG,EAAE;;EAEnB;EACA,IAAI,CAACC,MAAM,CAACC,IAAI,EAAEF,QAAQ,CAACG,IAAI,CAAC,uBAAuB,CAAC;EACxD,MAAMC,IAAI,GAAG,CACX,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,cAAc,CACf;EACDA,IAAI,CAACC,OAAO,CAAEC,CAAC,IAAK;IAClB;IACA,IAAI,CAACJ,IAAI,CAACI,CAAC,CAAC,EAAEN,QAAQ,CAACG,IAAI,CAAC,QAAQG,CAAC,UAAU,CAAC;EAClD,CAAC,CAAC;;EAEF;EACA,MAAMC,YAAY,GAChBL,IAAI,CAACM,cAAc,CAACC,kBAAkB,CAAC,CAACV,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAKA,MAAM;EAChE,MAAMW,WAAW,GACfR,IAAI,CAACS,YAAY,CAACF,kBAAkB,CAAC,CAACV,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAKA,MAAM;EAC9D,IAAI,CAACQ,YAAY,EAAEP,QAAQ,CAACG,IAAI,CAAC,GAAGJ,MAAM,kCAAkC,C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M,CAAC,MAAM,CAAC;IACpDC,IAAI,EAAE,IAAI7B,IAAI,CAACM,cAAc,CAACT,MAAM,EAAE;MAAEiC,SAAS,EAAE;IAAO,CAAC,CAAC,CAACF,MAAM,CACjE,IAAIG,IAAI,CAAC,YAAY,CACvB,CAAC;IACDC,OAAO,EAAE,IAAIhC,IAAI,CAACM,cAAc,CAACT,MAAM,EAAE;MAAEmC,OAAO,EAAE;IAAO,CAAC,CAAC,CAACJ,MAAM,CAClE,IAAIG,IAAI,CAAC,YAAY,CACvB;EACF,CAAC;EAED,MAAME,MAAM,GAAG;IACbC,EAAE,EAAEpC,QAAQ,CAACqC,MAAM,KAAK,CAAC;IACzBrC,QAAQ;IACRY,KAAK;IACLC,OAAO;IACPe;EACF,CAAC;EAED,IAAIO,MAAM,CAACC,EAAE,EAAE;IACbE,OAAO,CAACC,GAAG,CAAC,kCAAkCxC,MAAM,EAAE,EAAE6B,OAAO,CAAC;EAClE,CAAC,MAAM;IACLU,OAAO,CAACE,IAAI,CACV,sCAAsCzC,MAAM,GAAG,EAC/CC,QAAQ,EACR4B,OACF,CAAC;EACH;EACA,OAAOO,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["libraryDefaultLocale","testLocalePolyfill","locale","problems","global","Intl","push","apis","forEach","a","dtfSupported","DateTimeFormat","supportedLocalesOf","e","Error","message","String","nfSupported","NumberFormat","prSupported","PluralRules","rtfSupported","RelativeTimeFormat","lfSupported","ListFormat","dnSupported","DisplayNames","group","decimal","parts","formatToParts","find","p","type","value","pr","sample","select","rtf","format","lf","dn","of","loc","Locale","language","example","number","date","dateStyle","Date","weekday","pluralRule","relativeTime","list","displayName","result","ok","length","console","log","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,6BAA6B;AAElE,OAAO,SAASC,kBAAkBA,CAACC,MAAM,GAAGF,oBAAoB,EAAE;EAChE,MAAMG,QAAQ,GAAG,EAAE;;EAEn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,OAAO;EAC1B;EAEA,MAAMsD,MAAM,GAAG;IACbC,EAAE,EAAEtD,QAAQ,CAACuD,MAAM,KAAK,CAAC;IACzBvD,QAAQ;IACRwB,KAAK;IACLC,OAAO;IACPkB;EACF,CAAC;EAED,IAAIU,MAAM,CAACC,EAAE,EAAE;IACbE,OAAO,CAACC,GAAG,CAAC,kCAAkC1D,MAAM,EAAE,EAAE4C,OAAO,CAAC;EAClE,CAAC,MAAM;IACLa,OAAO,CAACE,IAAI,CACV,sCAAsC3D,MAAM,GAAG,EAC/CC,QAAQ,EACR2C,OACF,CAAC;EACH;EACA,OAAOU,MAAM;AACf","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { PluginObj, types } from '@babel/core';
2
- import type { PluginOptions } from './types';
2
+ import { type PluginOptions } from './types';
3
3
  export default function (babel: {
4
4
  types: typeof types;
5
- }, { locales, config, configFilePath, entryPointFilePath, }: PluginOptions): PluginObj;
5
+ }, { locales, config, configFilePath, entryPointFilePath, excludePolyfills, }: PluginOptions): PluginObj;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,CAAC,OAAO,WACZ,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EAC9B,EACE,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkE,GACnE,EAAE,aAAa,GACf,SAAS,CAkEX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1E,MAAM,CAAC,OAAO,WACZ,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EAC9B,EACE,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkE,EAClE,gBAAqB,GACtB,EAAE,aAAa,GACf,SAAS,CAuDX"}
@@ -1,3 +1,5 @@
1
+ export declare const POLYFILLS: readonly ["@formatjs/intl-getcanonicallocales/polyfill", "@formatjs/intl-locale/polyfill", "@formatjs/intl-displaynames/polyfill", "@formatjs/intl-listformat/polyfill", "@formatjs/intl-pluralrules/polyfill-force", "@formatjs/intl-numberformat/polyfill", "@formatjs/intl-relativetimeformat/polyfill", "@formatjs/intl-datetimeformat/polyfill", "@formatjs/intl-datetimeformat/add-all-tz"];
2
+ export declare const LOCALE_POLYFILLS: readonly ["@formatjs/intl-displaynames/locale-data", "@formatjs/intl-listformat/locale-data", "@formatjs/intl-pluralrules/locale-data", "@formatjs/intl-numberformat/locale-data", "@formatjs/intl-relativetimeformat/locale-data", "@formatjs/intl-datetimeformat/locale-data"];
1
3
  export interface PluginOptions {
2
4
  locales?: string[];
3
5
  config?: {
@@ -6,5 +8,6 @@ export interface PluginOptions {
6
8
  } & Record<string, any>;
7
9
  configFilePath?: string;
8
10
  entryPointFilePath?: string;
11
+ excludePolyfills?: (typeof POLYFILLS)[number][];
9
12
  }
10
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,mYAUZ,CAAC;AAEX,eAAO,MAAM,gBAAgB,kRAOnB,CAAC;AAEX,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,gBAAgB,CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;CACjD"}
@@ -1,12 +1,8 @@
1
- export declare function testLocalePolyfill(locale?: string): {
1
+ export declare function testLocalePolyfill(locale?: "en"): {
2
2
  ok: boolean;
3
3
  problems: string[];
4
4
  group: string | undefined;
5
5
  decimal: string | undefined;
6
- example: {
7
- number: string;
8
- date: string;
9
- weekday: string;
10
- };
6
+ example: Record<string, string>;
11
7
  };
12
8
  //# sourceMappingURL=testLocalePolyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testLocalePolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/tools/testLocalePolyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,MAAM,SAAU;;;;;;;;;;EAiFlD"}
1
+ {"version":3,"file":"testLocalePolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/tools/testLocalePolyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,MAAM,OAAuB;;;;;;EA0O/D"}
@@ -1,6 +1,6 @@
1
1
  import type { PluginObj, types } from '@babel/core';
2
- import type { PluginOptions } from './types';
2
+ import { type PluginOptions } from './types';
3
3
  export default function (babel: {
4
4
  types: typeof types;
5
- }, { locales, config, configFilePath, entryPointFilePath, }: PluginOptions): PluginObj;
5
+ }, { locales, config, configFilePath, entryPointFilePath, excludePolyfills, }: PluginOptions): PluginObj;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,CAAC,OAAO,WACZ,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EAC9B,EACE,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkE,GACnE,EAAE,aAAa,GACf,SAAS,CAkEX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1E,MAAM,CAAC,OAAO,WACZ,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EAC9B,EACE,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkE,EAClE,gBAAqB,GACtB,EAAE,aAAa,GACf,SAAS,CAuDX"}
@@ -1,3 +1,5 @@
1
+ export declare const POLYFILLS: readonly ["@formatjs/intl-getcanonicallocales/polyfill", "@formatjs/intl-locale/polyfill", "@formatjs/intl-displaynames/polyfill", "@formatjs/intl-listformat/polyfill", "@formatjs/intl-pluralrules/polyfill-force", "@formatjs/intl-numberformat/polyfill", "@formatjs/intl-relativetimeformat/polyfill", "@formatjs/intl-datetimeformat/polyfill", "@formatjs/intl-datetimeformat/add-all-tz"];
2
+ export declare const LOCALE_POLYFILLS: readonly ["@formatjs/intl-displaynames/locale-data", "@formatjs/intl-listformat/locale-data", "@formatjs/intl-pluralrules/locale-data", "@formatjs/intl-numberformat/locale-data", "@formatjs/intl-relativetimeformat/locale-data", "@formatjs/intl-datetimeformat/locale-data"];
1
3
  export interface PluginOptions {
2
4
  locales?: string[];
3
5
  config?: {
@@ -6,5 +8,6 @@ export interface PluginOptions {
6
8
  } & Record<string, any>;
7
9
  configFilePath?: string;
8
10
  entryPointFilePath?: string;
11
+ excludePolyfills?: (typeof POLYFILLS)[number][];
9
12
  }
10
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-dir/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,mYAUZ,CAAC;AAEX,eAAO,MAAM,gBAAgB,kRAOnB,CAAC;AAEX,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,gBAAgB,CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;CACjD"}
@@ -1,12 +1,8 @@
1
- export declare function testLocalePolyfill(locale?: string): {
1
+ export declare function testLocalePolyfill(locale?: "en"): {
2
2
  ok: boolean;
3
3
  problems: string[];
4
4
  group: string | undefined;
5
5
  decimal: string | undefined;
6
- example: {
7
- number: string;
8
- date: string;
9
- weekday: string;
10
- };
6
+ example: Record<string, string>;
11
7
  };
12
8
  //# sourceMappingURL=testLocalePolyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testLocalePolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/tools/testLocalePolyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,MAAM,SAAU;;;;;;;;;;EAiFlD"}
1
+ {"version":3,"file":"testLocalePolyfill.d.ts","sourceRoot":"","sources":["../../../../../src/tools/testLocalePolyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,MAAM,OAAuB;;;;;;EA0O/D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-react-native",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "An i18n package for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/module/src/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import type { PluginObj, types } from '@babel/core';
3
- import type { PluginOptions } from './types';
3
+ import { LOCALE_POLYFILLS, POLYFILLS, type PluginOptions } from './types';
4
4
  import { resolveLocales } from './utils/resolveLocales';
5
5
 
6
6
  export default function (
@@ -10,6 +10,7 @@ export default function (
10
10
  config,
11
11
  configFilePath,
12
12
  entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx'),
13
+ excludePolyfills = [],
13
14
  }: PluginOptions
14
15
  ): PluginObj {
15
16
  const { types: t } = babel;
@@ -35,22 +36,11 @@ export default function (
35
36
 
36
37
  // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
37
38
  const imports = [
38
- '@formatjs/intl-getcanonicallocales/polyfill',
39
- '@formatjs/intl-locale/polyfill',
40
- '@formatjs/intl-displaynames/polyfill',
41
- '@formatjs/intl-listformat/polyfill',
42
- '@formatjs/intl-pluralrules/polyfill-force', // https://github.com/formatjs/formatjs/issues/4463
43
- '@formatjs/intl-numberformat/polyfill',
44
- '@formatjs/intl-relativetimeformat/polyfill',
45
- '@formatjs/intl-datetimeformat/polyfill',
46
- '@formatjs/intl-datetimeformat/add-all-tz',
39
+ ...POLYFILLS.filter(
40
+ (polyfill) => !excludePolyfills.includes(polyfill)
41
+ ),
47
42
  ...resolvedLocales.flatMap((locale) => [
48
- `@formatjs/intl-displaynames/locale-data/${locale}`,
49
- `@formatjs/intl-listformat/locale-data/${locale}`,
50
- `@formatjs/intl-pluralrules/locale-data/${locale}`,
51
- `@formatjs/intl-numberformat/locale-data/${locale}`,
52
- `@formatjs/intl-relativetimeformat/locale-data/${locale}`,
53
- `@formatjs/intl-datetimeformat/locale-data/${locale}`,
43
+ ...LOCALE_POLYFILLS.map((localeData) => `${localeData}/${locale}`),
54
44
  ]),
55
45
  ];
56
46
 
@@ -1,3 +1,24 @@
1
+ export const POLYFILLS = [
2
+ '@formatjs/intl-getcanonicallocales/polyfill',
3
+ '@formatjs/intl-locale/polyfill',
4
+ '@formatjs/intl-displaynames/polyfill',
5
+ '@formatjs/intl-listformat/polyfill',
6
+ '@formatjs/intl-pluralrules/polyfill-force', // https://github.com/formatjs/formatjs/issues/4463
7
+ '@formatjs/intl-numberformat/polyfill',
8
+ '@formatjs/intl-relativetimeformat/polyfill',
9
+ '@formatjs/intl-datetimeformat/polyfill',
10
+ '@formatjs/intl-datetimeformat/add-all-tz',
11
+ ] as const;
12
+
13
+ export const LOCALE_POLYFILLS = [
14
+ `@formatjs/intl-displaynames/locale-data`,
15
+ `@formatjs/intl-listformat/locale-data`,
16
+ `@formatjs/intl-pluralrules/locale-data`,
17
+ `@formatjs/intl-numberformat/locale-data`,
18
+ `@formatjs/intl-relativetimeformat/locale-data`,
19
+ `@formatjs/intl-datetimeformat/locale-data`,
20
+ ] as const;
21
+
1
22
  export interface PluginOptions {
2
23
  /* List of locales to polyfill */
3
24
  locales?: string[];
@@ -7,4 +28,6 @@ export interface PluginOptions {
7
28
  configFilePath?: string;
8
29
  /* Resolved from package.json */
9
30
  entryPointFilePath?: string;
31
+ /* Polyfills to exclude */
32
+ excludePolyfills?: (typeof POLYFILLS)[number][];
10
33
  }
@@ -1,4 +1,6 @@
1
- export function testLocalePolyfill(locale = 'en-US') {
1
+ import { libraryDefaultLocale } from 'generaltranslation/internal';
2
+
3
+ export function testLocalePolyfill(locale = libraryDefaultLocale) {
2
4
  const problems = [];
3
5
 
4
6
  // 1. basic presence
@@ -18,12 +20,69 @@ export function testLocalePolyfill(locale = 'en-US') {
18
20
  });
19
21
 
20
22
  // 2. locale actually supported (no silent fallback)
21
- const dtfSupported =
22
- Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
23
- const nfSupported =
24
- Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
23
+ let dtfSupported = false;
24
+ try {
25
+ dtfSupported =
26
+ Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
27
+ } catch (e) {
28
+ problems.push(
29
+ `DateTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
30
+ );
31
+ }
32
+
33
+ let nfSupported = false;
34
+ try {
35
+ nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
36
+ } catch (e) {
37
+ problems.push(
38
+ `NumberFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
39
+ );
40
+ }
41
+
42
+ let prSupported = false;
43
+ try {
44
+ prSupported = Intl.PluralRules.supportedLocalesOf([locale])[0] === locale;
45
+ } catch (e) {
46
+ problems.push(
47
+ `PluralRules.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
48
+ );
49
+ }
50
+
51
+ let rtfSupported = false;
52
+ try {
53
+ rtfSupported =
54
+ Intl.RelativeTimeFormat.supportedLocalesOf([locale])[0] === locale;
55
+ } catch (e) {
56
+ problems.push(
57
+ `RelativeTimeFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
58
+ );
59
+ }
60
+
61
+ let lfSupported = false;
62
+ try {
63
+ lfSupported = Intl.ListFormat.supportedLocalesOf([locale])[0] === locale;
64
+ } catch (e) {
65
+ problems.push(
66
+ `ListFormat.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
67
+ );
68
+ }
69
+
70
+ let dnSupported = false;
71
+ try {
72
+ dnSupported = Intl.DisplayNames.supportedLocalesOf([locale])[0] === locale;
73
+ } catch (e) {
74
+ problems.push(
75
+ `DisplayNames.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`
76
+ );
77
+ }
78
+
25
79
  if (!dtfSupported) problems.push(`${locale} not supported by DateTimeFormat`);
26
80
  if (!nfSupported) problems.push(`${locale} not supported by NumberFormat`);
81
+ if (!prSupported) problems.push(`${locale} not supported by PluralRules`);
82
+ if (!rtfSupported)
83
+ problems.push(`${locale} not supported by RelativeTimeFormat`);
84
+ if (!lfSupported) problems.push(`${locale} not supported by ListFormat`);
85
+ if (!dnSupported) problems.push(`${locale} not supported by DisplayNames`);
27
86
 
28
87
  // 3. numeric separators sanity
29
88
  let group, decimal;
@@ -50,16 +109,112 @@ export function testLocalePolyfill(locale = 'en-US') {
50
109
  );
51
110
  }
52
111
 
53
- // 5. show example formatted values
54
- const example = {
55
- number: new Intl.NumberFormat(locale).format(1234.5),
56
- date: new Intl.DateTimeFormat(locale, { dateStyle: 'long' }).format(
57
- new Date('2020-01-02')
58
- ),
59
- weekday: new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(
60
- new Date('2020-01-02')
61
- ),
62
- };
112
+ // 5. relative time format sanity
113
+ try {
114
+ const rtf = new Intl.RelativeTimeFormat(locale);
115
+ const sample = rtf.format(-1, 'day');
116
+ if (!sample) problems.push('RelativeTimeFormat returned undefined');
117
+ } catch (e) {
118
+ problems.push(
119
+ `RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`
120
+ );
121
+ }
122
+
123
+ // 6. list format sanity
124
+ try {
125
+ const lf = new Intl.ListFormat(locale);
126
+ const sample = lf.format(['apple', 'orange', 'banana']);
127
+ if (!sample) problems.push('ListFormat returned undefined');
128
+ } catch (e) {
129
+ problems.push(
130
+ `ListFormat threw: ${e instanceof Error ? e.message : String(e)}`
131
+ );
132
+ }
133
+
134
+ // 7. display names sanity
135
+ try {
136
+ const dn = new Intl.DisplayNames(locale, { type: 'language' });
137
+ const sample = dn.of('en');
138
+ if (!sample) problems.push('DisplayNames returned undefined');
139
+ } catch (e) {
140
+ problems.push(
141
+ `DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`
142
+ );
143
+ }
144
+
145
+ // 8. locale sanity
146
+ try {
147
+ const loc = new Intl.Locale(locale);
148
+ if (!loc.language) problems.push('Locale missing language property');
149
+ } catch (e) {
150
+ problems.push(
151
+ `Locale threw: ${e instanceof Error ? e.message : String(e)}`
152
+ );
153
+ }
154
+
155
+ // 9. show example formatted values
156
+ const example: Record<string, string> = {};
157
+
158
+ try {
159
+ example.number = new Intl.NumberFormat(locale).format(1234.5);
160
+ } catch (e) {
161
+ example.number = 'ERROR';
162
+ }
163
+
164
+ try {
165
+ example.date = new Intl.DateTimeFormat(locale, {
166
+ dateStyle: 'long',
167
+ }).format(new Date('2020-01-02'));
168
+ } catch (e) {
169
+ example.date = 'ERROR';
170
+ }
171
+
172
+ try {
173
+ example.weekday = new Intl.DateTimeFormat(locale, {
174
+ weekday: 'long',
175
+ }).format(new Date('2020-01-02'));
176
+ } catch (e) {
177
+ example.weekday = 'ERROR';
178
+ }
179
+
180
+ try {
181
+ example.pluralRule = new Intl.PluralRules(locale).select(5);
182
+ } catch (e) {
183
+ example.pluralRule = 'ERROR';
184
+ }
185
+
186
+ try {
187
+ example.relativeTime = new Intl.RelativeTimeFormat(locale).format(
188
+ -1,
189
+ 'day'
190
+ );
191
+ } catch (e) {
192
+ example.relativeTime = 'ERROR';
193
+ }
194
+
195
+ try {
196
+ example.list = new Intl.ListFormat(locale).format([
197
+ 'apple',
198
+ 'orange',
199
+ 'banana',
200
+ ]);
201
+ } catch (e) {
202
+ example.list = 'ERROR';
203
+ }
204
+
205
+ try {
206
+ example.displayName =
207
+ new Intl.DisplayNames(locale, { type: 'language' }).of('en') ||
208
+ 'UNDEFINED';
209
+ } catch (e) {
210
+ example.displayName = 'ERROR';
211
+ }
212
+
213
+ try {
214
+ example.locale = new Intl.Locale(locale).language;
215
+ } catch (e) {
216
+ example.locale = 'ERROR';
217
+ }
63
218
 
64
219
  const result = {
65
220
  ok: problems.length === 0,