mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 05:43:55 +00:00
fix(app): add english to locale matchers (#16280)
This commit is contained in:
parent
eb9eb5e334
commit
f64bb91257
@ -146,6 +146,7 @@ const DICT: Record<Locale, Dictionary> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const localeMatchers: Array<{ locale: Locale; match: (language: string) => boolean }> = [
|
const localeMatchers: Array<{ locale: Locale; match: (language: string) => boolean }> = [
|
||||||
|
{ locale: "en", match: (language) => language.startsWith("en") },
|
||||||
{ locale: "zht", match: (language) => language.startsWith("zh") && language.includes("hant") },
|
{ locale: "zht", match: (language) => language.startsWith("zh") && language.includes("hant") },
|
||||||
{ locale: "zh", match: (language) => language.startsWith("zh") },
|
{ locale: "zh", match: (language) => language.startsWith("zh") },
|
||||||
{ locale: "ko", match: (language) => language.startsWith("ko") },
|
{ locale: "ko", match: (language) => language.startsWith("ko") },
|
||||||
@ -217,6 +218,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
|
|||||||
)
|
)
|
||||||
|
|
||||||
const locale = createMemo<Locale>(() => normalizeLocale(store.locale))
|
const locale = createMemo<Locale>(() => normalizeLocale(store.locale))
|
||||||
|
console.log("locale", locale())
|
||||||
const intl = createMemo(() => INTL[locale()])
|
const intl = createMemo(() => INTL[locale()])
|
||||||
|
|
||||||
const dict = createMemo<Dictionary>(() => DICT[locale()])
|
const dict = createMemo<Dictionary>(() => DICT[locale()])
|
||||||
|
|||||||
@ -76,6 +76,7 @@ function detectLocale(): Locale {
|
|||||||
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
|
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
if (!language) continue
|
if (!language) continue
|
||||||
|
if (language.toLowerCase().startsWith("en")) return "en"
|
||||||
if (language.toLowerCase().startsWith("zh")) {
|
if (language.toLowerCase().startsWith("zh")) {
|
||||||
if (language.toLowerCase().includes("hant")) return "zht"
|
if (language.toLowerCase().includes("hant")) return "zht"
|
||||||
return "zh"
|
return "zh"
|
||||||
|
|||||||
@ -77,6 +77,7 @@ function detectLocale(): Locale {
|
|||||||
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
|
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
if (!language) continue
|
if (!language) continue
|
||||||
|
if (language.toLowerCase().startsWith("en")) return "en"
|
||||||
if (language.toLowerCase().startsWith("zh")) {
|
if (language.toLowerCase().startsWith("zh")) {
|
||||||
if (language.toLowerCase().includes("hant")) return "zht"
|
if (language.toLowerCase().includes("hant")) return "zht"
|
||||||
return "zh"
|
return "zh"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user