0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

Merge pull request #1459 from logto-io/charles-log-3476-fix-ac-language-detection

fix(console): admin console language detection
This commit is contained in:
Charles Zhao 2022-07-08 11:40:54 +08:00 committed by GitHub
commit e7dada812f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;