Skip to content

Internationalization ​

Locale files live under:

text
src/locales/langs/
├── en-US/common.json
├── ja-JP/common.json
└── zh-CN/common.json

src/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 ​

  1. Create src/locales/langs/<locale>/common.json.
  2. Keep message keys aligned across locales.
  3. Add the locale to SUPPORTED_LOCALES.
  4. 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.

Released under the MIT License