From c38c469fddaae5b407232ec14412fb4a4957e790 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Tue, 4 May 2021 08:35:55 +0800 Subject: [PATCH] Change Intl.Locale to basic string Safari < 14 cannot use Intl.Locale --- src/i18n.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i18n.js b/src/i18n.js index a6576cea..d25c9b6b 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -18,7 +18,7 @@ $locale.subscribe((value) => { currentLocale = value; if (typeof window !== 'undefined') { - localStorage.setItem('locale', new Intl.Locale(value).language); + localStorage.setItem('locale', value); } }); @@ -32,7 +32,7 @@ export function startClient() { init({ ...INIT_OPTIONS, - initialLocale: savedLocale !== null ? savedLocale : getLocaleFromNavigator(), + initialLocale: savedLocale !== null ? savedLocale : getLocaleFromNavigator().substring(0, 2), }); } @@ -58,7 +58,7 @@ export function i18nMiddleware() { } if (locale != null && locale !== currentLocale) { - $locale.set(locale); + $locale.set(locale.substring(0, 2)); } next();