From 1f1510460057f8dedff2379c3572254993d4d020 Mon Sep 17 00:00:00 2001 From: "rudraswamy.c" Date: Fri, 28 Jun 2024 11:31:06 +0530 Subject: [PATCH 1/3] PWA-3294 :PLP should displayed on all store view --- packages/venia-ui/lib/components/App/localeProvider.js | 9 ++++++++- packages/venia-ui/lib/util/formatLocale.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/venia-ui/lib/components/App/localeProvider.js b/packages/venia-ui/lib/components/App/localeProvider.js index 2bdcb7e19c..78737b950c 100644 --- a/packages/venia-ui/lib/components/App/localeProvider.js +++ b/packages/venia-ui/lib/components/App/localeProvider.js @@ -19,10 +19,17 @@ 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'; + } + 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]); 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, '-'); }; From c114d4cd83669eec8c3ad59eda36a94976250d9f Mon Sep 17 00:00:00 2001 From: "rudraswamy.c" Date: Fri, 28 Jun 2024 11:45:20 +0530 Subject: [PATCH 2/3] PWA-3294 :fixed lint error --- packages/venia-ui/lib/components/App/localeProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/venia-ui/lib/components/App/localeProvider.js b/packages/venia-ui/lib/components/App/localeProvider.js index 78737b950c..18f4d4e1a5 100644 --- a/packages/venia-ui/lib/components/App/localeProvider.js +++ b/packages/venia-ui/lib/components/App/localeProvider.js @@ -31,7 +31,7 @@ const LocaleProvider = props => { return data && 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 From ac0def17c2e56abb915b786801256e664b4b65d0 Mon Sep 17 00:00:00 2001 From: "rudraswamy.c" Date: Mon, 1 Jul 2024 11:41:33 +0530 Subject: [PATCH 3/3] PWA-3294 :dupilcate if condition removed --- packages/venia-ui/lib/components/App/localeProvider.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/venia-ui/lib/components/App/localeProvider.js b/packages/venia-ui/lib/components/App/localeProvider.js index 18f4d4e1a5..668281159f 100644 --- a/packages/venia-ui/lib/components/App/localeProvider.js +++ b/packages/venia-ui/lib/components/App/localeProvider.js @@ -23,15 +23,12 @@ const LocaleProvider = props => { if (locale === 'zh_Hant_TW') { locale = 'zh_TW'; } - if (locale === 'zh_Hant_TW') { - locale = 'zh_TW'; - } const language = useMemo(() => { return data && data.storeConfig.locale ? toReactIntl(locale) : DEFAULT_LOCALE; - }, [data,locale]); + }, [data, locale]); /** * At build time, `__fetchLocaleData__` is injected as a global. Depending on the environment, this global will be