@shopify/react-i18n
Advanced tools
Comparing version 7.5.0 to 7.5.1
@@ -19,2 +19,4 @@ 'use strict'; | ||
const SEPARATOR = '.'; | ||
const UNICODE_NUMBERING_SYSTEM = '-u-nu-'; | ||
const LATIN = 'latn'; | ||
@@ -43,6 +45,14 @@ const isString = value => typeof value === 'string'; | ||
function latinLocale(locale) { | ||
if (!locale) return locale; | ||
return new Intl.Locale(locale, { | ||
numberingSystem: 'latn' | ||
}).toString(); | ||
if (!locale) return locale; // Intl.Locale was added to iOS in v14. See https://caniuse.com/?search=Intl.Locale | ||
// We still support ios 12/13, so we need to check if this works and fallback to the default behaviour if not | ||
try { | ||
return new Intl.Locale(locale, { | ||
numberingSystem: LATIN | ||
}).toString(); | ||
} catch { | ||
const numberingSystemRegex = new RegExp(`(?:-x|${UNICODE_NUMBERING_SYSTEM}).*`, 'g'); | ||
const latinNumberingSystem = `${UNICODE_NUMBERING_SYSTEM}${LATIN}`; | ||
return locale.replace(numberingSystemRegex, '').concat(latinNumberingSystem); | ||
} | ||
} | ||
@@ -49,0 +59,0 @@ |
{ | ||
"name": "@shopify/react-i18n", | ||
"version": "7.5.0", | ||
"version": "7.5.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "i18n utilities for React handling translations, formatting, and more", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
280869
4232