Change Intl.Locale to basic string

Safari < 14 cannot use Intl.Locale
This commit is contained in:
Made Baruna 2021-05-04 08:35:55 +08:00
parent 96ddf54859
commit c38c469fdd
No known key found for this signature in database
GPG key ID: 5AA5DA16AA5DCEAD

View file

@ -18,7 +18,7 @@ $locale.subscribe((value) => {
currentLocale = value; currentLocale = value;
if (typeof window !== 'undefined') { 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({
...INIT_OPTIONS, ...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) { if (locale != null && locale !== currentLocale) {
$locale.set(locale); $locale.set(locale.substring(0, 2));
} }
next(); next();