Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import polyfillNumberFormat from './polyfillNumberFormat';
import polyfillListFormat from './polyfillListFormat';
import IntlPolyfill from './types';

/**
* Polyfill the Intl API, always performed for native devices.
*/
export default function polyfill() {
const intlPolyfill: IntlPolyfill = () => {
// Native devices require extra polyfills
require('@formatjs/intl-getcanonicallocales/polyfill');
require('@formatjs/intl-locale/polyfill');
require('@formatjs/intl-pluralrules/polyfill');
require('@formatjs/intl-datetimeformat');
polyfillNumberFormat();
polyfillListFormat();
}
};

export default intlPolyfill;
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import polyfillNumberFormat from './polyfillNumberFormat';
import IntlPolyfill from './types';

/**
* Polyfill the Intl API if the ICU version is old.
* This ensures that the currency data is consistent across platforms and browsers.
*/
export default function intlPolyfill() {
const intlPolyfill: IntlPolyfill = () => {
// Just need to polyfill Intl.NumberFormat for web based platforms
polyfillNumberFormat();
require('@formatjs/intl-datetimeformat');
}
};
export default intlPolyfill;
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import CONST from '../../CONST';
/**
* Check if the locale data is as expected on the device.
* Ensures that the currency data is consistent across devices.
* @returns {Boolean}
*/
function hasOldCurrencyData() {
function hasOldCurrencyData(): boolean {
return (
new Intl.NumberFormat(CONST.LOCALES.DEFAULT, {
style: CONST.POLYFILL_TEST.STYLE,
currency: CONST.POLYFILL_TEST.CURRENCY,
currencyDisplay: CONST.POLYFILL_TEST.FORMAT,
}).format(CONST.POLYFILL_TEST.SAMPLE_INPUT) !== CONST.POLYFILL_TEST.EXPECTED_OUTPUT
}).format(Number(CONST.POLYFILL_TEST.SAMPLE_INPUT)) !== CONST.POLYFILL_TEST.EXPECTED_OUTPUT
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/libs/IntlPolyfill/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type IntlPolyfill = () => void;

export default IntlPolyfill;