0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

fix(console): admin console language detection

This commit is contained in:
Charles Zhao 2022-07-07 22:43:26 +08:00
parent a0936f3b03
commit a8f18e53a2
No known key found for this signature in database
GPG key ID: 4858774754C92DF2
2 changed files with 2 additions and 4 deletions

View file

@ -11,7 +11,7 @@ import { themeStorageKey } from '@/consts';
import useApi, { RequestError } from './use-api';
const userPreferencesGuard = z.object({
language: z.nativeEnum(Language),
language: z.nativeEnum(Language).optional(),
appearanceMode: z.nativeEnum(AppearanceMode),
experienceNoticeConfirmed: z.boolean().optional(),
getStartedHidden: z.boolean().optional(),
@ -39,7 +39,6 @@ const useUserPreferences = () => {
return z.object({ [key]: userPreferencesGuard }).parse(data).adminConsolePreferences;
} catch {
return {
language: Language.English,
appearanceMode:
getEnumFromArray(Object.values(AppearanceMode), localStorage.getItem(themeStorageKey)) ??
AppearanceMode.SyncWithSystem,

View file

@ -1,5 +1,4 @@
import resources, { Language } from '@logto/phrases';
import { conditional } from '@silverhand/essentials';
import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
@ -14,11 +13,11 @@ const initI18n = async (language?: Language) =>
interpolation: {
escapeValue: false,
},
lng: language,
detection: {
lookupLocalStorage: 'i18nextLogtoAcLng',
lookupSessionStorage: 'i18nextLogtoAcLng',
},
...conditional(language && { lng: language }),
});
export default initI18n;