BitFun icon indicating copy to clipboard operation
BitFun copied to clipboard

refactor(i18n): track cross-surface i18n and l10n governance

Open limityan opened this issue 6 months ago • 11 comments

## Background

BitFun aligned i18n and l10n across Web UI, mobile-web, installer, backend, and relay static pages around one shared language contract. Each product surface still owns and loads only the resources it needs.

Completion Status

This refactor stream is complete after the active closure PR is merged. Future i18n drift should be handled as ordinary maintenance using the documented architecture, audit reports, and lightweight verification rules.

Final Architecture Snapshot

  • Canonical locale identity, aliases, fallback chains, surface defaults, and generated contracts are centralized.
  • Product surfaces keep independent resource ownership and do not import another surface's full locale catalog.
  • Shared terms are reserved for stable cross-surface concepts such as product names, feature names, tool names, modes, connection methods, and status labels.
  • Context-specific page, workflow, toast, validation, and feature copy stays in the nearest owner namespace.
  • Static keys, dynamic keys, placeholder parity, literal fallbacks, direct locale formatting, shared-term duplicates, same-text locale inventory, and actionable l10n signals are audited as separate categories.
  • Local prechecks stay lightweight; broader platform/build coverage remains protected by CI.

Final Progress Snapshot

  • Unified locale contract and generated surface contracts are in place across frontend/backend surfaces.
  • Web UI keeps bootstrap namespaces separate from lazy locale namespaces.
  • mobile-web, installer, backend, and relay static pages have their own resource paths and generated contract entry points.
  • Shared terms are available across surfaces and are used for stable mode, agent, tool, connection-method, product, feature, and Deep Review labels without forcing cross-surface bundle loading.
  • Dynamic-key candidates are explicitly tracked with source-proof metadata for known dynamic access paths.
  • Static Web UI literal fallback debt and direct locale-formatting candidates are zero.
  • Broad zh-CN/zh-TW same-text copy is visible as non-blocking review inventory; actionable l10n signal candidates stay separate at zero.
  • Durable i18n docs cover resource ownership, lookup rules, audit semantics, and lightweight verification.

Final Key Metrics

Baseline is the earliest tracked governance snapshot for each comparable metric in this refactor stream.

Metric Baseline Final Change / meaning
Literal fallback candidates 457 0 -457
Direct locale-format candidates 32 0 -32
Shared-term duplicate candidates 214 185 -29; remaining entries are governed no-growth review data
Dynamic key candidates 194 193 -1; all current dynamic candidates are source-proven
Dynamic candidates with source proof 0 193 +193
Actionable same-text l10n signal candidates 1 0 -1 actual signal fixed
Same-text locale review inventory not reported 790 Non-blocking copy-review inventory; not a pass/fail metric
Confirmed unused keys 0 0 0

Post-Close Guardrails

  • Keep source-proof metadata current for dynamic key access.
  • Migrate shared-term duplicates only when the local value is the same stable concept; keep context-sensitive copy local.
  • Treat same-text locale inventory as copy-review input, not deletion evidence or a pass/fail quality metric.
  • Keep static defaultValue fallback and direct locale-format candidates at zero by repairing locale resources or using surface i18n helpers.
  • Adding a future locale or product surface must update generated contracts, resource boundaries, fallback rules, and audit coverage together.

Done Criteria

  • Adding a locale or product surface has clear contract, resource ownership, fallback, generation, and audit entry points.
  • Product surfaces do not load resource catalogs they do not own.
  • Key deletion can rule out static and dynamic references with auditable evidence.
  • Stable concept labels have an authoritative source, repeated values have a reviewable report, and l10n signal issues are tracked separately from structural i18n cleanup.
  • Durable docs are enough for future contributors to add, read, migrate, and audit i18n resources consistently.

limityan avatar May 30 '26 04:05 limityan

Update from #972 (refactor(i18n): tighten shared terms and dynamic key proofs).

Key Comparison

Metric Before After Delta
Shared-term duplicate candidates 214 211 -3
Installer shared-term duplicates 3 0 -3
product.name duplicate candidates 6 3 -3
Dynamic key candidates 194 194 0
Dynamic candidates with source references 0 194 +194

Notes:

  • Installer titlebar defaults now read shared.product.name; copied titlebar.default keys were removed.
  • Dynamic-key contracts now require audited sourceReferences, so future cleanup can distinguish documented dynamic access from removable keys.

limityan avatar May 30 '26 09:05 limityan

Follow-up snapshot for PR #977.

This PR continues the i18n/l10n governance track without closing this issue. It adds audit visibility for literal fallback and direct locale-formatting debt, lowers several existing debt baselines, keeps remaining work visible for later cleanup, and adds a review follow-up so direct Intl.* calls without new cannot bypass the locale-format audit.

Metric Before After #977 Delta
Confirmed unused keys 0 0 0
Dynamic key candidates 194 193 -1
Shared-term duplicate candidates 206 201 -5
L10n quality candidates 1093 1087 -6
Literal defaultValue fallbacks 457 396 -61
Direct locale-format calls 32 24 -8

Review/CI follow-up:

  • Fixed Web UI test mocks that still depended on literal fallback behavior after static fallback strings were removed.
  • Hardened the locale-format audit to catch both new Intl.* and bare Intl.* calls, plus existing toLocale* calls.
  • GitHub Actions CI passed on a3c966bf: Frontend Build and all Rust Build Check jobs for ubuntu-latest, macos-15, and windows-latest.
  • Local validation includes i18n contract/audit/report, Web UI full tests, Web/Mobile type checks, Web/Mobile builds, repo hygiene, GitHub config, and diff hygiene.

Remaining work is still tracked here rather than tied to PR closure: continue reducing Web UI literal fallbacks, review high-confidence zh-TW localization candidates, migrate only semantically stable shared concept labels, and move the remaining direct locale-formatting call sites behind surface i18n helpers.

limityan avatar May 30 '26 11:05 limityan

Update: PR #990 continues the i18n/l10n cleanup stream and combines the planned PR A + PR B scope into one reviewable PR.

Functional snapshot:

  • Web UI flow-chat/Deep Review literal fallback debt was reduced where keys already exist in locale resources.
  • Web UI and Mobile Web date/number formatting now routes through owned i18n formatting helpers at product call sites.
  • zh-TW high-confidence terminology was improved across Web UI, Mobile Web, installer, and core resources while keeping locale files readable UTF-8.
  • Governance reporting now keeps zero-count surfaces visible, which makes future surface regressions easier to detect.
  • Remaining direct locale-format debt is isolated to two core miniapp assets and stays tracked by the baseline.
Metric Before After Change
Literal fallback candidates 396 149 -247
Direct locale-format candidates 24 2 -22
l10n quality candidates 1087 768 -319
Shared-term duplicate candidates 201 201 0
Mobile Web l10n candidates 19 0 -19

Verification for PR #990 includes i18n audit/contract, Web UI type-check/lint/tests, Mobile Web type-check, and repo hygiene. Heavy installer/desktop builds were left to CI for this i18n-focused slice.

limityan avatar Jun 01 '26 02:06 limityan

P0 follow-up: #995 restores the latest i18n governance snapshot after the zh-TW write-tool-mode label regression.

Metric Before After Change
l10n quality candidates 769 768 -1
Web UI l10n candidates 726 725 -1
settings/agentic-tools l10n candidates 6 5 -1

This keeps the top-level issue snapshot unchanged at the intended 768 l10n-quality-candidate state.

limityan avatar Jun 01 '26 03:06 limityan

Progress update from #1002:

Metric Before After Change
Literal fallback candidates 149 87 -62
Direct locale-format candidates 2 0 -2
l10n quality candidates 768 768 0
Shared-term duplicate candidates 201 201 0
Dynamic key candidates 193 193 0

Scope snapshot:

  • Removed low-risk Web UI literal defaultValue fallbacks where locale resources already own the copy.
  • Reduced direct locale-format candidates to zero in the tracked audit surface.
  • Remaining literal fallback debt is isolated to ReviewTeamPage, FlowChatHeader, AgentsScene, TaskDetailPanel, and ReviewConfig.

Validation: i18n:audit, i18n:contract:test:ci, type-check:web, full Web UI tests, repo hygiene, and git diff --check passed. lint:web also passed with the existing startupTrace.ts warnings.

limityan avatar Jun 01 '26 06:06 limityan

Progress update: opened #1004 to clear the remaining static Web UI literal fallback debt and keep the baseline empty going forward.

Metric Before After Change
Literal fallback candidates 87 0 -87
Direct locale-format candidates 0 0 0
Confirmed unused keys 0 0 0
Dynamic key candidates 193 193 0
Shared-term duplicate candidates 201 201 0
l10n quality candidates 768 768 0

Scope: removed static component defaultValue copy from the remaining Web UI fallback hotspots, kept runtime-data fallbacks for dynamic member/team data, and updated durable i18n docs to make the empty fallback baseline explicit.

Validation: i18n:audit, i18n:contract:test:ci, type-check:web, full Web UI tests, lint:web, repo hygiene, and git diff --check passed on the rebased branch. lint:web still reports the existing startupTrace.ts unused-disable warnings.

limityan avatar Jun 01 '26 07:06 limityan

Progress update: #1004 now also removes the composed policySummaryDescription static fallback and extends i18n:audit to catch composed static defaultValue expressions.

Metric Current
Literal fallback candidates 0
Direct locale-format candidates 0
Confirmed unused keys 0

Additional validation includes an audit integration case for composed defaultValue fallbacks, plus the existing i18n audit, contract, type-check, full Web UI test, lint, hygiene, and diff checks.

limityan avatar Jun 01 '26 07:06 limityan

Progress update: opened #1009 to tighten the l10n quality signal and condense durable i18n guidance.

Metric Before After Change
L10n quality candidates 768 0 -768
Literal fallback candidates 0 0 0
Direct locale-format candidates 0 0 0
Confirmed unused keys 0 0 0
Dynamic key candidates 193 193 0
Shared-term duplicate candidates 201 201 0
i18n architecture doc lines 204 134 -70
i18n development guide lines 222 152 -70

Scope: same-text zh-CN / zh-TW l10n findings now require an actionable script or terminology signal, the current 瞭解更多 wording gap is fixed, obsolete identical-copy allowlist entries are removed, and durable docs now describe the stable contract, resource ownership, loading, key, and audit rules more compactly.

Validation: pnpm run i18n:contract:test, pnpm run i18n:audit, pnpm run check:repo-hygiene, and git diff --check gcwing/main...HEAD passed after rebasing onto latest gcwing/main.

limityan avatar Jun 01 '26 08:06 limityan

Correction on the #1009 metric wording:

Metric Previous wording Correct interpretation
L10n quality candidates 768 -> 0 This was mostly an audit-definition change from broad same-text detection to actionable signal detection, not 768 translated strings
Actionable same-text l10n signal candidates not separated 1 -> 0, with one actual zh-TW resource fix: 了解更多 -> 瞭解更多
Shared-term duplicate candidates 201 -> 201 Unchanged; this remains the next cleanup focus

I updated the #1009 PR body and this issue's top-level snapshot so future tracking distinguishes legacy broad same-text inventory from actual l10n signal cleanup.

limityan avatar Jun 01 '26 09:06 limityan

Progress update for #1012:

  • Restores broad zh-CN/zh-TW same-text visibility as a non-blocking sameTextLocaleInventory report category.
  • Consolidates additional stable labels to shared terms across mobile-web and Web UI while keeping product-surface resource ownership separate.
  • Lowers the shared-term duplicate no-growth baseline after the real code/resource cleanup.
Metric Before After
Shared-term duplicate candidates 201 185
Mobile-web shared-term duplicates 6 0
Web UI shared-term duplicates 180 170
Same-text locale review inventory not reported 790
L10n quality candidates 0 0

Validation recorded in the PR: i18n contract test, i18n audit, Web UI type-check, mobile-web type-check, focused DeepReview i18n test, repo hygiene, and diff whitespace check.

limityan avatar Jun 01 '26 09:06 limityan

Closure update:

#1012 is now the closure PR for this issue. After it merges, the issue can close; remaining i18n/l10n concerns are governed by the documented architecture, audit categories, and no-growth baselines rather than tracked as a separate refactor stream.

Metric Final
Literal fallback candidates 0
Direct locale-format candidates 0
Confirmed unused keys 0
Actionable l10n signal candidates 0
Shared-term duplicate candidates 185
Same-text locale review inventory 790

limityan avatar Jun 01 '26 09:06 limityan