越野跑排行榜越野跑排行榜

命令面板

搜索要运行的命令...

Internationalization

Internationalization

The web UI supports zh-CN and en. Chinese is the default for every visitor; the site does not automatically choose a language from the browser.

Switching languages

The language switcher in the navigation toggles between Chinese and English. The choice is stored in localStorage under leaderboard.locale and restored on the next visit. Switching does not change the URL, and the initial HTML is always Chinese because the site is statically exported.

Message catalogs

Messages live in apps/leaderboard-web/lib/i18n/messages/en.ts. Keys are the Chinese source strings; the English catalog maps each Chinese key to its English text. The zh-CN lookup falls back to the key itself, and the English lookup falls back to zh-CN and then the key.

To add a message:

  1. Add the Chinese source string to en.ts and its English translation.
  2. Use t("中文文案") in a client component, or <T k="中文文案" /> in a server component.
  3. Use named parameters such as {count} and pass them with t("共 {count} 位跑者", { count }).

Data values (runner names, event names, badge names) are not translated. Docs content and server metadata remain in their authored language.

Scope and limitations

  • UI copy only: navigation, pages, forms, charts, empty/error/loading states.
  • No locale-prefixed routes or middleware; this keeps output: "export" working.
  • English is applied after hydration, so a visitor with a saved English preference may briefly see the Chinese HTML.
  • Add new keys to both languages; the catalog test checks English values and interpolation.