mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-13 21:43:42 +08:00
Merge remote-tracking branch 'upstream/main'
# Conflicts: # app/api/auth.ts # app/api/common.ts # app/azure.ts # app/client/api.ts # app/client/platforms/openai.ts # app/components/chat.tsx # app/components/settings.tsx # app/constant.ts # app/layout.tsx # app/masks/index.ts # app/store/chat.ts # app/store/config.ts # app/utils/hooks.ts # app/utils/model.ts # package.json # yarn.lock
This commit is contained in:
@@ -97,7 +97,17 @@ function setItem(key: string, value: string) {
|
||||
|
||||
function getLanguage() {
|
||||
try {
|
||||
return navigator.language.toLowerCase();
|
||||
const locale = new Intl.Locale(navigator.language).maximize();
|
||||
const region = locale?.region?.toLowerCase();
|
||||
// 1. check region code in ALL_LANGS
|
||||
if (AllLangs.includes(region as Lang)) {
|
||||
return region as Lang;
|
||||
}
|
||||
// 2. check language code in ALL_LANGS
|
||||
if (AllLangs.includes(locale.language as Lang)) {
|
||||
return locale.language as Lang;
|
||||
}
|
||||
return DEFAULT_LANG;
|
||||
} catch {
|
||||
return DEFAULT_LANG;
|
||||
}
|
||||
@@ -110,15 +120,7 @@ export function getLang(): Lang {
|
||||
return savedLang as Lang;
|
||||
}
|
||||
|
||||
const lang = getLanguage();
|
||||
|
||||
for (const option of AllLangs) {
|
||||
if (lang.includes(option)) {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
return DEFAULT_LANG;
|
||||
return getLanguage();
|
||||
}
|
||||
|
||||
export function changeLang(lang: Lang) {
|
||||
|
Reference in New Issue
Block a user