Skip to content

A full-featured download manager.

4.1 KB
Raw Blame

description: Internationalization contracts for renderer/main strings and locale resources paths: ["src/renderer//*.ts", "src/renderer//.tsx", "src/main/**/.ts", "src/core/i18n/", "src/core/plugin/plugin-registry", "src/core/plugin/capabilities/i18n", "src/core/plugin/manifest/i18n-resolve*", "src/server/index.ts", "src/server/operator-admin*.ts", "src/shared/constants/locales*.ts", "src/shared/schemas/locale*.ts", "src/shared/i18n-resources.ts", "src/shared/locales/*.json", "scripts/check-i18n.mjs", "tests/scripts/check-i18n.test.ts"]

Internationalization

Every user-visible application or operator string must use i18next; do not hardcode UI labels, messages, notifications, dialogs, or CLI output. Renderer components use react-i18next; Electron main uses the initialized instance from src/main/lib/i18n.ts; the server operator CLI creates an isolated instance from shared resources. Keep t in React hook dependency arrays. Route host-wide locale changes through LocaleCoordinator: serialize changes, skip stale revisions, reconcile late targets, and publish LocaleChanged only after the current apply succeeds. Keep plugin-registry and capability-host locale changes transactional, including rollback on failure.

Resource contract

  • src/shared/locales/en-US.json is the key-shape source of truth. Add every logical key to every locale registered in SUPPORTED_LOCALES; never update only a subset.
  • src/shared/i18n-resources.ts statically and exhaustively registers loaders for those locale files. Only English and Simplified Chinese are eager; await resource loading before committing a host or renderer language change. New languages also require a catalog entry in src/shared/constants/locales.ts and a matching JSON resource.
  • The server operator CLI uses src/server/operator-admin-locales.ts to import only the operatorAdmin namespace from every catalog. Keep its locale map exhaustive; importing full application catalogs into the CLI duplicates Web UI resources in the Server package and can exceed its size budget.
  • Every translation leaf is a string. Keep readable locale files as UTF-8; avoid unnecessary \uXXXX escapes.
  • English user-visible prose, including matching test fixtures and assertions, uses the typographic apostrophe ’ for contractions and possessives; do not substitute the ASCII apostrophe '. Keep ' only where technical syntax or an external data contract requires that exact character.
  • Preserve the exact {{placeholder}} set across every locale and every plural variant.
  • Plural keys use i18next category suffixes. Supply every cardinal category returned by Intl.PluralRules(locale); _zero is the only permitted extra category because i18next treats it as an exact-zero override.

Namespaces

Keys follow the feature that owns them and use camelCase leaves; descriptions normally pair name with nameDesc.

  • Settings grid cards: settings.cards.<card>.*
  • Settings dialogs/pages: settings.<dialog>.*
  • BitTorrent settings and tracker defaults: settings.bittorrent.*
  • Tracker management: trackers.effective.*, trackers.blacklist.*, trackers.combobox.*, and trackers.sync.*

Extend the relevant namespace rather than creating a parallel spelling or placing tracker UI under settings merely because trackers are configurable.

Marketplace locale independence

Application locales and registry listing locales are separate contracts. SupportedLocale must not constrain listing.defaultLocale or keys in the registry's open BCP 47 listing.localizations map. Resolve marketplace display and search text with the vendored registry resolver; do not use resolveSupportedLocale or infer sibling regions such as zh-TW -> zh-CN.

Verification

Run pnpm run check:i18n after any locale, catalog, placeholder, plural, or resource-registration change. It verifies file/catalog parity, logical key coverage, plural categories, string leaves, and placeholder parity. Its tests must use temporary fixtures and never rewrite real locale files. Tests that render translated components load the real renderer initialization with:

import '@renderer/lib/i18n'