Internationalization
Locale files live under:
text
src/locales/langs/
├── en-US/common.json
├── ja-JP/common.json
└── zh-CN/common.jsonsrc/locales/index.ts scans JSON with import.meta.glob and lazy-loads messages by locale and namespace. The selected locale is stored under the lang localStorage key; zh-CN is the default.
Add a Locale
- Create
src/locales/langs/<locale>/common.json. - Keep message keys aligned across locales.
- Add the locale to
SUPPORTED_LOCALES. - Call
setLang('<locale>').
ts
import { setLang } from "@/locales";
await setLang("en-US");The loader updates Vue I18n, persists the selection, and synchronizes page content, bottom navigation, route titles, document.title, and the document's lang attribute.
Route titles store keys such as common.routes.home. Tabs and example lists use computed; do not store setup-time t() results in a plain array because those values would not react to locale changes.