mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -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:
commit
e7dada812f
2 changed files with 2 additions and 4 deletions
|
@ -11,7 +11,7 @@ import { themeStorageKey } from '@/consts';
|
||||||
import useApi, { RequestError } from './use-api';
|
import useApi, { RequestError } from './use-api';
|
||||||
|
|
||||||
const userPreferencesGuard = z.object({
|
const userPreferencesGuard = z.object({
|
||||||
language: z.nativeEnum(Language),
|
language: z.nativeEnum(Language).optional(),
|
||||||
appearanceMode: z.nativeEnum(AppearanceMode),
|
appearanceMode: z.nativeEnum(AppearanceMode),
|
||||||
experienceNoticeConfirmed: z.boolean().optional(),
|
experienceNoticeConfirmed: z.boolean().optional(),
|
||||||
getStartedHidden: z.boolean().optional(),
|
getStartedHidden: z.boolean().optional(),
|
||||||
|
@ -39,7 +39,6 @@ const useUserPreferences = () => {
|
||||||
return z.object({ [key]: userPreferencesGuard }).parse(data).adminConsolePreferences;
|
return z.object({ [key]: userPreferencesGuard }).parse(data).adminConsolePreferences;
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
language: Language.English,
|
|
||||||
appearanceMode:
|
appearanceMode:
|
||||||
getEnumFromArray(Object.values(AppearanceMode), localStorage.getItem(themeStorageKey)) ??
|
getEnumFromArray(Object.values(AppearanceMode), localStorage.getItem(themeStorageKey)) ??
|
||||||
AppearanceMode.SyncWithSystem,
|
AppearanceMode.SyncWithSystem,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import resources, { Language } from '@logto/phrases';
|
import resources, { Language } from '@logto/phrases';
|
||||||
import { conditional } from '@silverhand/essentials';
|
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
@ -14,11 +13,11 @@ const initI18n = async (language?: Language) =>
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
|
lng: language,
|
||||||
detection: {
|
detection: {
|
||||||
lookupLocalStorage: 'i18nextLogtoAcLng',
|
lookupLocalStorage: 'i18nextLogtoAcLng',
|
||||||
lookupSessionStorage: 'i18nextLogtoAcLng',
|
lookupSessionStorage: 'i18nextLogtoAcLng',
|
||||||
},
|
},
|
||||||
...conditional(language && { lng: language }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default initI18n;
|
export default initI18n;
|
||||||
|
|
Loading…
Add table
Reference in a new issue