Skip to content

refactor: harden i18n audit coverage#952

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/i18n-pr3
May 29, 2026
Merged

refactor: harden i18n audit coverage#952
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/i18n-pr3

Conversation

@limityan
Copy link
Copy Markdown
Collaborator

@limityan limityan commented May 29, 2026

Summary

  • Add CI coverage for pnpm run i18n:contract:test and pnpm run i18n:audit before frontend build steps.
  • Extend i18n:audit to enforce placeholder parity across Web UI JSON, mobile-web messages, installer JSON, core Fluent resources, and relay static homepage resources.
  • Validate direct static Web UI i18nService.t('namespace:key') keys, direct literal fallback arguments, relay homepage data-i18n key parity, and canonical relay locale ids.
  • Reduce the hardcoded CJK source baseline to zero for audited Web UI, mobile-web, installer, and relay static homepage sources.
  • Move existing hardcoded CJK candidates into owned resource/data files:
    • Web UI processing hints into a lazy flow-chat/processing-hints namespace.
    • Relay static homepage copy and language-switcher labels into a local canonical-locale i18n.json with English HTML fallback.
    • Settings search aliases into the settings locale resources instead of encoded CJK source strings.
    • Provider error match phrases, Monaco expansion labels, and bundled pet display metadata into small data resources.
  • Fix current missing/parity issues, including common:tabs.pullRequests, mobile-web {suffix} placeholder parity, remote-session-missing, and locale-derived mobile-web Other option matching.
  • Update AGENTS.md, AGENTS-CN.md, CONTRIBUTING.md, CONTRIBUTING_CN.md, and i18n docs with concise guidance for minimal checks and i18n access rules.

Risk / behavior notes

  • CI and local i18n:audit are stricter now. Future PRs that add mismatched placeholders, missing direct static keys, direct literal fallback arguments, non-canonical relay locale ids, relay homepage key drift, or CJK source text in audited files will fail until the copy is moved to the right resource owner.
  • Web UI processing hints now lazy-load through their own namespace instead of being bundled as a source constant, keeping them out of bootstrap namespaces.
  • Settings nav now reads locale-specific search aliases from the settings namespace; search behavior should stay equivalent while avoiding encoded CJK strings in TS source.
  • Relay homepage now fetches local i18n.json; if fetching fails, the page keeps the English fallback HTML and en-US document language. The language button cycles en-US, zh-CN, and zh-TW so every canonical locale is reachable from the static page.
  • Mobile-web plural suffix remains English-only at render time, so Chinese locales keep placeholder parity without displaying an extra s.
  • Mobile-web Other option detection is derived from locale resources plus the protocol-level other fallback, preserving cross-language compatibility without reintroducing source CJK text.

Adversarial review fixes

  • Changed relay homepage resources from zh/en to canonical zh-CN, zh-TW, and en-US locale ids.
  • Added relay homepage resource audit for canonical locale coverage, key parity, data-i18n usage, and placeholder parity.
  • Added relay homepage three-locale language cycling so zh-TW is reachable without depending on browser language.
  • Aligned relay homepage fallback <html lang> with the English fallback copy.
  • Fixed mobile-web placeholder parity so Chinese strings do not display an English plural suffix.
  • Hardened mobile-web Other option matching so old or cross-locale labels are still treated as custom-answer options.
  • Moved settings search aliases out of \uXXXX encoded TS literals and into locale resources; changed files now only retain \u001f, a required control separator.
  • Rechecked that no process/plan documents are included in the PR.

Verification

  • pnpm run i18n:contract:test
  • pnpm run i18n:audit
  • pnpm run type-check:web
  • pnpm --dir src/mobile-web run type-check
  • pnpm --dir src/web-ui run test:run src/infrastructure/i18n/core/I18nService.test.ts
  • pnpm run check:github-config
  • pnpm run check:repo-hygiene
  • git diff --check

@limityan limityan force-pushed the yanzhn/i18n-pr3 branch 4 times, most recently from 76998ff to e7d2f81 Compare May 29, 2026 11:44
@limityan limityan merged commit 4af010d into GCWing:main May 29, 2026
4 checks passed
@limityan
Copy link
Copy Markdown
Collaborator Author

Related tracking issue: #959. This link is for i18n/l10n module context only and should not close the issue when this PR is merged or closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant