Skip to content

Added i18n guidance to AGENTS.md#27177

Merged
rob-ghost merged 1 commit intomainfrom
chore/claude-md-i18n-docs
Apr 7, 2026
Merged

Added i18n guidance to AGENTS.md#27177
rob-ghost merged 1 commit intomainfrom
chore/claude-md-i18n-docs

Conversation

@rob-ghost
Copy link
Copy Markdown
Contributor

Summary

  • Expanded the i18n Architecture section in AGENTS.md with practical rules for developers and AI agents
  • Documents the translation workflow (yarn translate), CI enforcement, and key rules:
    • Never split sentences across multiple t() calls
    • Always provide context descriptions in context.json
    • Use @doist/react-interpolate for inline elements (<a>, <strong>, etc.)
    • Use {variable} interpolation for dynamic values
  • Includes correct/incorrect code examples and a reference to the canonical example

Why

Translation contributors flagged that split-sentence keys prevent proper localization. This documentation ensures developers and agents building new features know the rules without needing to discover them through trial and error.

Test plan

  • Review the added documentation for accuracy and completeness

Expanded the i18n Architecture section with practical rules for
developers and agents: never split sentences across t() calls, always
provide context descriptions, use @doist/react-interpolate for inline
elements, and run yarn translate after changing translation keys.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Walkthrough

The pull request adds internationalization (i18n) documentation to AGENTS.md. It specifies requirements for a required context.json file where every translation key must include a non-empty description. It introduces translation maintenance workflow commands and defines CI/test behaviors where translation validation runs as part of tests and CI fails if translation keys or context.json are out of date. New translation authoring rules are documented, including preventing sentence splitting across multiple t() calls, enforcing context descriptions, using {variable} syntax for interpolation, and specifying inline element handling with <tag> syntax.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added i18n guidance to AGENTS.md' accurately summarizes the main change—expanding documentation with translation guidelines.
Description check ✅ Passed The description clearly explains the changes, their purpose, and provides context about why the documentation was added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/claude-md-i18n-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@AGENTS.md`:
- Around line 164-169: Update the documentation and enforcement so they match:
either relax the AGENTS.md wording to say non-empty context descriptions are
"required by convention" or (recommended) add explicit validation in
generate-context.js to fail CI when any context.json entry has an empty
description; implement a check (e.g., in the function that reads/generates
context.json) that iterates entries, detects empty or whitespace-only
descriptions, logs a descriptive error and exits non-zero (process.exit(1)), and
then update AGENTS.md to state that CI will fail on empty descriptions. Include
references to context.json and the generate-context.js validation function so
reviewers can find the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a00b04b1-b6ec-4cfd-8118-9311adf63d89

📥 Commits

Reviewing files that changed from the base of the PR and between 17492ed and ac53d5b.

📒 Files selected for processing (1)
  • AGENTS.md

Comment on lines +164 to +169
`yarn translate` is run as part of `yarn workspace @tryghost/i18n test`. In CI, it fails if translation keys or `context.json` are out of date (`failOnUpdate: process.env.CI`). Always run `yarn translate` after adding or changing `t()` calls.

**Rules for Translation Keys:**
1. **Never split sentences across multiple `t()` calls.** Translators cannot reorder words across separate keys. Instead, use `@doist/react-interpolate` to embed React elements (links, bold, etc.) within a single translatable string.
2. **Always provide context descriptions.** When adding a new key, add a description in `context.json` explaining where the string appears and what it does. CI will reject empty descriptions.
3. **Use interpolation for dynamic values.** Ghost uses `{variable}` syntax: `t('Welcome back, {name}!', {name: firstname})`
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.

⚠️ Potential issue | 🟡 Minor

Clarify CI enforcement wording for empty context descriptions.

The docs state CI rejects empty descriptions, but the referenced enforcement shown in ghost/i18n/generate-context.js only fails when context.json is out of date, not when values are empty. Consider either (a) tightening wording to “required by convention” or (b) adding explicit validation logic for non-empty descriptions and then documenting that behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 164 - 169, Update the documentation and enforcement
so they match: either relax the AGENTS.md wording to say non-empty context
descriptions are "required by convention" or (recommended) add explicit
validation in generate-context.js to fail CI when any context.json entry has an
empty description; implement a check (e.g., in the function that reads/generates
context.json) that iterates entries, detects empty or whitespace-only
descriptions, logs a descriptive error and exits non-zero (process.exit(1)), and
then update AGENTS.md to state that CI will fail on empty descriptions. Include
references to context.json and the generate-context.js validation function so
reviewers can find the change.

@rob-ghost rob-ghost merged commit 04df2dd into main Apr 7, 2026
38 checks passed
@rob-ghost rob-ghost deleted the chore/claude-md-i18n-docs branch April 7, 2026 09:48
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.

2 participants