fix(i18n): check every locale module, not the three named ones - #2631
Open
Longado wants to merge 1 commit into
Open
fix(i18n): check every locale module, not the three named ones#2631Longado wants to merge 1 commit into
Longado wants to merge 1 commit into
Conversation
`check-i18n` discovered manifests through a three-name allowlist
(`tuttiI18nModule`, `agentGuiI18nModule`, `browserNodeI18nModule`), while
docs/conventions/static-analysis.md documents those same three as examples
("such as") of a package-specific name. Four shipped manifests chose names
outside the list and were therefore never checked at all: richTextI18nModule,
issueManagerI18nModule, terminalNodeI18nModule and
workspaceUserProjectI18nModule.
Discovery now matches any `export const <name>I18nModule`; non-manifest
matches are still dropped by parseExportedObjectLiteral returning null.
The remaining changes are what that coverage requires, not separate concerns:
- All four previously-skipped manifests name their namespace through a
sibling constant (`namespace: richTextI18nNamespace`) rather than a
literal, which threw ReferenceError once they were discovered. The
manifest VM context now carries the module's top-level double-quoted
string constants.
- Interpolated strings were read as static text, so `label: `@${label}``
was reported as hardcoded copy and `t(`status.${status}`)` as a missing
key. Copy that is only placeholders plus punctuation is no longer
reported, and a key composed at runtime is skipped; prose that survives
placeholder removal ("Hello ${name}, welcome") still reports.
- controllerActionTestHarness.ts is imported only by *.test.ts, so the
TestHarness suffix now carries the same exemption .test.ts does.
Coverage goes from 4317 keys / 2082 source files to 4604 / 2275.
Verification: removing `status.running` from the terminal module's zh-CN
locale passes on main and is caught here as
`locale-key-missing terminalNode.status.running`; the new test asserts that
and fails without this change.
Signed-off-by: Eddie Lin <ltalpha51759@gmail.com>
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
check-i18ndiscovered locale-module manifests through a hardcoded three-name allowlist (tuttiI18nModule,agentGuiI18nModule,browserNodeI18nModule), whiledocs/conventions/static-analysis.mddocuments those same three as non-exhaustive examples of a package-specific name ("such as"). Four shipped manifests chose names outside the list and were silently excluded from every i18n check (locale-key parity, placeholder parity, hardcoded-copy scan):richTextI18nModule(packages/ui/rich-text)issueManagerI18nModule(packages/workspace/issue-manager)terminalNodeI18nModule(packages/workspace/terminal)workspaceUserProjectI18nModule(packages/workspace/user-project)Discovery now matches any
export const <name>I18nModule; non-manifest matches are still discarded byparseExportedObjectLiteralreturningnull.The remaining changes are what that coverage requires, not separate concerns:
namespace: richTextI18nNamespace) rather than a literal, which threwReferenceErroronce they were discovered. The manifest VM context now carries the module's top-level double-quoted string constants.label: `@${label}`was reported as hardcoded copy andt(`status.${status}`)as a missing key. Copy that is only placeholders plus punctuation is no longer reported, and a key composed at runtime is skipped; prose that survives placeholder removal (Hello ${name}, welcome) still reports.controllerActionTestHarness.ts(imported only by*.test.tsfiles) gets the same exemption.test.tscarries, via aTestHarness.ts(x)suffix entry.Coverage grows from 4,317 keys / 2,082 source files to 4,604 / 2,275. No user-visible behavior changes; this is a check-script fix.
Verification
node --test tools/scripts/check-i18n.test.mjs— 15/15 pass (13 existing + 2 new)node tools/scripts/check-i18n.mjs— passes on the real tree at the new coverageoxfmt --checkclean on both filesstatus.runningfrom the terminal module's zh-CN locale passes silently onmainand is caught by this branch aslocale-key-missing terminalNode.status.running. The new regression test asserts exactly that and fails against the unmodified script.Checklist
docs/conventions/static-analysis.mdalready describes the intended (example-based) behavior; the script now matches it, so no doc change is needed.git commit -s).