Fix i18n lang bug (#858) (#867)

This commit is contained in:
chinrunja
2026-05-20 04:47:52 +00:00
committed by GitHub
parent 5fc7dce9c8
commit 479fef8a84
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -19,6 +19,8 @@ server/dist
packages/server/dist
*.local
ROADMAP.md
pnpm-lock.yaml
pnpm-workspace.yaml
# Server data
packages/server/data/
packages/server/node_modules/
+6
View File
@@ -33,7 +33,12 @@ function resolveLocale(saved: string | null): SupportedLocale {
return 'en'
}
function setHtmlLang(locale: SupportedLocale) {
document.documentElement.lang = locale
}
const locale = resolveLocale(saved)
setHtmlLang(locale)
export const i18n = createI18n({
legacy: false,
@@ -44,4 +49,5 @@ export const i18n = createI18n({
export function switchLocale(newLocale: string): void {
;(i18n.global.locale as any).value = newLocale
setHtmlLang(newLocale as SupportedLocale)
}