merge main

This commit is contained in:
lloydzhou
2024-07-11 15:29:47 +08:00
46 changed files with 2619 additions and 325 deletions

View File

@@ -347,6 +347,44 @@ const cn = {
SubTitle: "选择一个特定的 API 版本",
},
},
Baidu: {
ApiKey: {
Title: "接口密钥",
SubTitle: "使用自定义 Baidu API Key",
Placeholder: "Baidu API Key",
},
SecretKey: {
Title: "接口密钥",
SubTitle: "使用自定义 Baidu Secret Key",
Placeholder: "Baidu Secret Key",
},
Endpoint: {
Title: "接口地址",
SubTitle: "样例:",
},
},
ByteDance: {
ApiKey: {
Title: "接口密钥",
SubTitle: "使用自定义 ByteDance API Key",
Placeholder: "ByteDance API Key",
},
Endpoint: {
Title: "接口地址",
SubTitle: "样例:",
},
},
Alibaba: {
ApiKey: {
Title: "接口密钥",
SubTitle: "使用自定义阿里云API Key",
Placeholder: "Alibaba Cloud API Key",
},
Endpoint: {
Title: "接口地址",
SubTitle: "样例:",
},
},
CustomModel: {
Title: "自定义模型名",
SubTitle: "增加自定义模型可选项,使用英文逗号隔开",

View File

@@ -334,6 +334,44 @@ const en: LocaleType = {
SubTitle: "Select and input a specific API version",
},
},
Baidu: {
ApiKey: {
Title: "Baidu API Key",
SubTitle: "Use a custom Baidu API Key",
Placeholder: "Baidu API Key",
},
SecretKey: {
Title: "Baidu Secret Key",
SubTitle: "Use a custom Baidu Secret Key",
Placeholder: "Baidu Secret Key",
},
Endpoint: {
Title: "Endpoint Address",
SubTitle: "Example:",
},
},
ByteDance: {
ApiKey: {
Title: "ByteDance API Key",
SubTitle: "Use a custom ByteDance API Key",
Placeholder: "ByteDance API Key",
},
Endpoint: {
Title: "Endpoint Address",
SubTitle: "Example:",
},
},
Alibaba: {
ApiKey: {
Title: "Alibaba API Key",
SubTitle: "Use a custom Alibaba Cloud API Key",
Placeholder: "Alibaba Cloud API Key",
},
Endpoint: {
Title: "Endpoint Address",
SubTitle: "Example:",
},
},
CustomModel: {
Title: "Custom Models",
SubTitle: "Custom model options, seperated by comma",

View File

@@ -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) {