Skip to content

fix(i18n): skip regex fragments in the translation check - #223

Open
Caldalis wants to merge 1 commit into
OpenBMB:mainfrom
Caldalis:fix/i18n-check-regex-fragment
Open

fix(i18n): skip regex fragments in the translation check#223
Caldalis wants to merge 1 commit into
OpenBMB:mainfrom
Caldalis:fix/i18n-check-regex-fragment

Conversation

@Caldalis

Copy link
Copy Markdown

Problem

npm --prefix frontend-enterprise run i18n:check currently exits 1 on main:

Missing English translations (1):
- src/pages/chat/chatHelpers.tsx:1707:string: "(?:参考来源|参考资料|引用来源|资料来源)"

The literal was introduced by 120ce01 (fix(chat): deduplicate knowledge citations). It is the citation-heading pattern that
stripTrailingCitationSummary compiles into a RegExp — not UI copy. check-i18n.cjs flags every Chinese string literal that has no en.json entry and cannot tell the two apart, so it reports the regex as a missing translation.

Change

Add the fragment to the ignoredFragments allowlist that already exists in check-i18n.cjs, plus a short comment recording what that list is for.

Why not add it to en.json

localizeTextNode / localizeAttribute in src/i18n/index.tsx perform DOM-level replacement over text nodes and attributes; they never touch JS values. This fragment cannot reach the DOM, so an en.json entry would be a permanently unmatched row and would mix non-UI strings into the translation catalog. ignoredFragments exists for exactly this case and already carries after:content-['展开'] (a CSS content value).

Risk

Low. Only the validation script changes — no runtime code, no build output, and en.json is untouched.

Tests

Run on this branch:

  • npm --prefix frontend-enterprise run i18n:check — passes (3235 translations)
  • npm --prefix frontend-enterprise test — 50 files / 243 tests passed
  • npm --prefix frontend-enterprise run build — passes (includes tsc -b)
  • npm --prefix frontend-enterprise run config:check — passes

UI validation

Not applicable: this changes only a script under frontend-enterprise/scripts/ and affects no route or rendered output, so there are no routes/roles to verify and no screenshots.

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