Skip to content

docs(kb): fix the <T> example that the CLI rejects - #608

Closed
Kevin-Liu-01 wants to merge 2 commits into
mainfrom
k/docs-kb-t-example
Closed

Kevin-Liu-01 wants to merge 2 commits into
mainfrom
k/docs-kb-t-example

Conversation

@Kevin-Liu-01

Copy link
Copy Markdown
Contributor

Summary

The "Translating code directly" example in the KB article "Can I do i18n without translation files?" puts {itemCount} and {discount && <p>{discount}% discount applied!</p>} directly inside <T>. The CLI does not accept dynamic children in <T>, and the <T> reference says to wrap them in variable components (react/reference/components/t.mdx:31). A reader who copies the example cannot translate it.

Checked with gt 2.26.1 on the article's example (kb/i18n-without-translation-files.mdx:50-64), in a project with gt-react 11.4.11 in package.json:

  • npx gt validate exits 1: <T> component has children that could change at runtime. Use a variable component like <Var> to ensure this content is translated., quoting {itemCount} and the {discount && ...} line.
  • npx gt generate and npx gt translate --dry-run exit 1 with CLI tool encountered 1 syntax errors while scanning for translatable content. To ignore these errors, re-run with --ignore-errors.

Changes

  • kb/i18n-without-translation-files.mdx: the example wraps the item count in <Num> and replaces the && conditional with <Branch branch={discount > 0} true={...} />, which renders the discount line only when there is a discount. The discount is also a <Num>. A new sentence after the example says that runtime values go in variable components, conditional content goes in <Branch>, and the CLI stops with an error otherwise.

Size: 1 file, +8/-3.

Test plan

  • The new example, saved as src/CheckoutSummary.tsx and byte-identical to the code block: npx gt validate prints "Success! Found 1 translatable entries for gt-react", and npx gt generate and npx gt translate --dry-run exit 0.
  • Rendered with gt-react 11.4.11 (initializeGT and GTProvider, English): discount={10} gives "10% discount applied!", discount={0} and no discount leave the line out, and itemCount={1200} renders "1,200". The <Branch> code in @generaltranslation/react-core 11.4.11 renders the prop named after String(branch) and otherwise its children, so false renders nothing here.

Run on this branch (k/docs-kb-t-example at 755ad83, on origin/main f93de7c), in scripts/ after npm ci:

  • validate-links: all links valid
  • validate:unsafe-html and validate:callouts: 546 MDX files each, clean
  • validate:reference-links: 500 MDX files against 301 reference symbol aliases, clean
  • validate:structure, validate:blog-order and validate:kb (5 articles): clean
  • test: 7 scripts, 155 cases passed
  • typecheck: clean
  • The CI check for javascript: URLs in MDX finds nothing, and the changed article parses with the MDX parser the validators use.

Open PRs #595 (publish dates) and #597 (wording later in the article) edit the same file. Both merge cleanly with this branch (git merge-tree).

🤖 Generated with Claude Code

The inline example in "Can I do i18n without translation files?" put
{itemCount} and a {discount && ...} conditional straight inside <T>.
gt 2.26.1 stops validate, generate and translate with "<T> component
has children that could change at runtime". The example now wraps the
values in <Num> and the conditional in <Branch>, and a sentence says
why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kevin-Liu-01
Kevin-Liu-01 requested review from a team as code owners October 12, 2026 06:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved. This is a one-file knowledge-base example fix with a small, reversible blast radius; Bugbot and Security Agent were not running, and no other signals require human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router

Resolved conflicts in kb/en-US/i18n-without-translation-files.mdx (moved from kb/ on main; the example fix applies unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kevin-Liu-01

Copy link
Copy Markdown
Contributor Author

Covered by #650 (merged): it replaced the <T> example the CLI rejected.

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