diff --git a/packages/venia-ui/lib/components/App/localeProvider.js b/packages/venia-ui/lib/components/App/localeProvider.js index 2bdcb7e19c..668281159f 100644 --- a/packages/venia-ui/lib/components/App/localeProvider.js +++ b/packages/venia-ui/lib/components/App/localeProvider.js @@ -19,12 +19,16 @@ const LocaleProvider = props => { fetchPolicy: 'cache-and-network', nextFetchPolicy: 'cache-first' }); + let locale = data !== undefined ? data.storeConfig.locale : DEFAULT_LOCALE; + if (locale === 'zh_Hant_TW') { + locale = 'zh_TW'; + } const language = useMemo(() => { return data && data.storeConfig.locale - ? toReactIntl(data.storeConfig.locale) + ? toReactIntl(locale) : DEFAULT_LOCALE; - }, [data]); + }, [data, locale]); /** * At build time, `__fetchLocaleData__` is injected as a global. Depending on the environment, this global will be diff --git a/packages/venia-ui/lib/util/formatLocale.js b/packages/venia-ui/lib/util/formatLocale.js index b10550af3b..c25786095c 100644 --- a/packages/venia-ui/lib/util/formatLocale.js +++ b/packages/venia-ui/lib/util/formatLocale.js @@ -5,7 +5,7 @@ * @returns {string} A locale string (e.g. `fr_FR`). */ export const fromReactIntl = string => { - return string.replace('-', '_'); + return string.replace(/-/g, '_'); }; /** @@ -15,5 +15,5 @@ export const fromReactIntl = string => { * @returns {string} A string (e.g. `fr-FR`). */ export const toReactIntl = string => { - return string.replace('_', '-'); + return string.replace(/_/g, '-'); };