Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="zh-cmn-Hans">
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" />
Expand Down
2 changes: 2 additions & 0 deletions src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const $t = i18n.global.t as App.I18n.$T;

export function setLocale(locale: App.I18n.LangType) {
i18n.global.locale.value = locale;

document?.querySelector('html')?.setAttribute('lang', locale);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document?.querySelector(...) doesn’t actually guard against document being undefined in non-browser runtimes (it will still throw a ReferenceError when evaluating document). If you want this to be safe outside the browser (e.g., during Node-based tooling), use globalThis.document (or a typeof document !== 'undefined' check) and prefer documentElement over querySelector('html').

Suggested change
document?.querySelector('html')?.setAttribute('lang', locale);
globalThis.document?.documentElement?.setAttribute('lang', locale);

Copilot uses AI. Check for mistakes.
}
Comment on lines 24 to 28
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only updates the <html lang> attribute when setLocale() is called; on initial load the i18n locale is set from localStg in createI18n(...), but setLocale() is never invoked (and the store’s locale watcher is not immediate). As a result, a persisted en-US locale can still leave index.html’s lang at zh-CN until the user manually changes language. Consider syncing <html lang> once during app startup (e.g., in setupI18n() or by calling a dedicated syncHtmlLang(getLocale()) during setup).

Copilot uses AI. Check for mistakes.

export function getLocale(): App.I18n.LangType {
Expand Down
Loading