Skip to content

Commit

Permalink
single function for common imports
Browse files Browse the repository at this point in the history
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
  • Loading branch information
Prince-Mendiratta committed Feb 20, 2023
1 parent 1618249 commit 98924d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/libs/IntlPolyfill/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shouldPolyfill from './shouldPolyfill';
import polyfillNumberFormat from './polyfillNumberFormat';

/**
* Polyfill the Intl API if the ICU version is old.
Expand All @@ -10,9 +11,5 @@ export default function intlPolyfill() {
}

// Just need to polyfill Intl.NumberFormat for web based platforms
require('@formatjs/intl-numberformat/polyfill-force');

// Load en & es Locale data
require('@formatjs/intl-numberformat/locale-data/en');
require('@formatjs/intl-numberformat/locale-data/es');
polyfillNumberFormat();
}
7 changes: 2 additions & 5 deletions src/libs/IntlPolyfill/index.native.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shouldPolyfill from './shouldPolyfill';
import polyfillNumberFormat from './polyfillNumberFormat';

/**
* Polyfill the Intl API, always performed for native devices.
Expand All @@ -12,9 +13,5 @@ export default function polyfill() {
require('@formatjs/intl-getcanonicallocales/polyfill');
require('@formatjs/intl-locale/polyfill');
require('@formatjs/intl-pluralrules/polyfill');
require('@formatjs/intl-numberformat/polyfill-force');

// Load en & es Locale data
require('@formatjs/intl-numberformat/locale-data/en');
require('@formatjs/intl-numberformat/locale-data/es');
polyfillNumberFormat();
}
13 changes: 13 additions & 0 deletions src/libs/IntlPolyfill/polyfillNumberFormat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Common imports that are required for all platforms
*/

function polyfillNumberFormat() {
require('@formatjs/intl-numberformat/polyfill-force');

// Load en & es Locale data
require('@formatjs/intl-numberformat/locale-data/en');
require('@formatjs/intl-numberformat/locale-data/es');
}

export default polyfillNumberFormat;

0 comments on commit 98924d4

Please sign in to comment.