refactor(i18n): centralize locale-aware rendering - #41432
Open
opencode-agent[bot] wants to merge 1 commit into
Open
refactor(i18n): centralize locale-aware rendering#41432opencode-agent[bot] wants to merge 1 commit into
opencode-agent[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit evidence
The weekly audit ran against
devat0bff28de0910and covered the app, shared UI, session UI, and desktop translation surfaces.Dictionary parity was already clean across English plus 61 non-English locales, including placeholders, CLDR plural categories, desktop-native bundles, locale detection, and ICU support. The deeper invariant scan found:
AnimatedCountLabelselected CLDR categories and constructed.one/.otherlookup keys in component code. Its singular/other suffix algorithm also assumed English-like morphology and ignoredzero,two,few, andmanytransitions.locale() === "en"in feature code to choose runtime English payloads versus dictionary copy.Web Search/{{provider}} Web Searchpairs, and Sinhala retained EnglishRenderinside a translated action.The production-string scan found no additional high-confidence hardcoded web or desktop copy after excluding tests, developer-only UI, product/provider/tool names, URLs, code tokens, keyboard legends, acronyms, assets, and established technical borrowings.
Shared API
createUiI18n(...)now enriches the existing translation source with three narrow operations:tDynamic(key, source, params)preserves runtime-generated English copy for English locale tags and selects dictionary copy for other locales.parts(key, slots)inserts typed rich values into complete phrase templates in dictionary-authored order.pluralParts(key, count, slots, params)selects the CLDR plural template and inserts an animated count without exposing categories or lookup suffixes to components.Call sites no longer inspect locales, choose plural categories, construct lookup keys, or assemble grammatical fragments.
AnimatedCountLabelstill animates digits, but intentionally drops the English-specific noun-tail animation.Phrase migration
All 62 UI dictionaries replace:
ui.lineComment.label.prefix+.suffixwithui.lineComment.label: "...{{selection}}..."ui.lineComment.editorLabel.prefix+.suffixwithui.lineComment.editorLabel: "...{{selection}}..."ui.list.emptyWithFilter.prefix+.suffixwithui.list.emptyWithFilter: "...{{query}}..."A mechanical verification compared every new template with
origin/devand proved it equals the old prefix + typed slot + suffix byte-for-byte. Japanese/Korean suffix order and Chinese surrounding text remain dictionary-controlled. Parity tests require every rich key to contain exactly one expected slot and reject all legacy fragment keys.Translation research
The retained-English review used repository terminology plus Unicode CLDR script identity, Firefox/Pontoon, KDE localization, and official/local public-sector terminology where maintained corpora were unavailable.
ওয়েব অনুসন্ধানཡོངས་འབྲེལ་འཚོལ་ཞིབ།वेब खोजpadictionary:ویب تلاشවෙබ් සෙවුම{{provider}}is preserved exactly. SinhalaRenderbecomes the dictionary’s existing rendering term,විදැහුම්.Sources included Mozilla Firefox/Pontoon, KDE translation memory, CLDR likely-subtag data, the Dzongkha Development Commission, and repository-local prior art. The broader standards mismatch where bare
panormally implies Gurmukhi while this repository’s dictionary is Shahmukhi remains outside this focused fix.Checks
CI=true bun test ./src/i18n/parity.test.ts ./src/i18n/desktop-native.test.tsfrompackages/appbun test ./src/context/i18n.test.tsfrompackages/uibun typecheckfrompackages/app,packages/ui,packages/session-ui, andpackages/enterpriseoxlint— 0 errorsgit diff --checkRequested by: @Hona (Hona via Slack)