From 8780bc8269e0b77237a75442af689525543fa812 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Wed, 5 Jun 2024 12:22:08 +0800 Subject: [PATCH] Fix: compat with the navigator language return with underslash (#6907) * fix: compat with the naviator language return with underslash * Update CHANGELOG.md --- packages/plugin-intl/CHANGELOG.md | 4 ++++ packages/plugin-intl/package.json | 2 +- packages/plugin-intl/src/runtime.tsx | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/plugin-intl/CHANGELOG.md b/packages/plugin-intl/CHANGELOG.md index 1ade93256c..361c15fe90 100644 --- a/packages/plugin-intl/CHANGELOG.md +++ b/packages/plugin-intl/CHANGELOG.md @@ -1,5 +1,9 @@ # @ice/plugin-intl +## 1.0.2 + +fix: compat with the navigator language return with underslash. + ## 1.0.1 ### Patch Changes diff --git a/packages/plugin-intl/package.json b/packages/plugin-intl/package.json index 67f897422b..c907706d24 100644 --- a/packages/plugin-intl/package.json +++ b/packages/plugin-intl/package.json @@ -1,6 +1,6 @@ { "name": "@ice/plugin-intl", - "version": "1.0.1", + "version": "1.0.2", "description": "react intl plugin for ice.js 3.", "files": [ "esm", diff --git a/packages/plugin-intl/src/runtime.tsx b/packages/plugin-intl/src/runtime.tsx index 5d4139a736..e2831bdfdc 100644 --- a/packages/plugin-intl/src/runtime.tsx +++ b/packages/plugin-intl/src/runtime.tsx @@ -9,9 +9,10 @@ const cache = createIntlCache(); const getDefaultLocale = () => { // @ts-ignore - return (typeof window !== 'undefined' && window.__ICE_DEFAULT_LOCALE__) || + const defaultLocale = (typeof window !== 'undefined' && window.__ICE_DEFAULT_LOCALE__) || (typeof navigator !== 'undefined' && navigator.language) || 'zh-CN'; + return defaultLocale.replace('_', '-'); }; const getLocaleMessages = () => {