fix: default setup language to system locale (#500)
This commit is contained in:
committed by
GitHub
Unverified
parent
04aa94f907
commit
08960d700f
@@ -1,5 +1,10 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import {
|
||||
SUPPORTED_LANGUAGE_CODES,
|
||||
resolveSupportedLanguage,
|
||||
type LanguageCode,
|
||||
} from '../../shared/language';
|
||||
|
||||
// EN
|
||||
import enCommon from './locales/en/common.json';
|
||||
@@ -38,9 +43,7 @@ export const SUPPORTED_LANGUAGES = [
|
||||
{ code: 'en', label: 'English' },
|
||||
{ code: 'zh', label: '中文' },
|
||||
{ code: 'ja', label: '日本語' },
|
||||
] as const;
|
||||
|
||||
export type LanguageCode = (typeof SUPPORTED_LANGUAGES)[number]['code'];
|
||||
] as const satisfies ReadonlyArray<{ code: LanguageCode; label: string }>;
|
||||
|
||||
const resources = {
|
||||
en: {
|
||||
@@ -82,8 +85,9 @@ i18n
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources,
|
||||
lng: 'en', // will be overridden by settings store
|
||||
lng: resolveSupportedLanguage(typeof navigator !== 'undefined' ? navigator.language : undefined),
|
||||
fallbackLng: 'en',
|
||||
supportedLngs: [...SUPPORTED_LANGUAGE_CODES],
|
||||
defaultNS: 'common',
|
||||
ns: ['common', 'settings', 'dashboard', 'chat', 'channels', 'agents', 'skills', 'cron', 'setup'],
|
||||
interpolation: {
|
||||
|
||||
Reference in New Issue
Block a user