Skip to content

fix(gottext): keep only the calls naming the template's text domain - #101

Merged
SirLouen merged 2 commits into
mainfrom
fix/100
Oct 18, 2026
Merged

SirLouen merged 2 commits into
mainfrom
fix/100

Conversation

@SirLouen

@SirLouen SirLouen commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Closes #100

What

A template now lists only the messages of its own text domain. A call naming no domain belongs to default, as in the WordPress packages. A call whose domain is not written as a string stays in, because the template cannot tell its domain. Go markers and templates are read as before.

This breaks one setup. An app that loads its catalogue under the default domain now builds its template with domain: 'default'.

Why

An app may show the block editor's own words through plain calls such as __('Move up'). Those words landed in the app's template. Its untranslated gate then asked its translators for words the app never reads.

Testing Instructions

The repository's own gates cover the extraction rules. To check a real app, build its template with this branch and compare it with the committed one. Only messages from calls naming another domain, or no domain, should leave.

Summary by CodeRabbit

  • Behavior Changes
    • Message extraction now retains calls only when their domain matches the requested domain. Calls without an explicit domain are included only for the default domain; calls with a non-literal domain are retained.
    • Go markers and templates continue to be read as before.
  • Breaking Change
    • If your catalogue loads under default, set domain: 'default' when building its template.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d30a75ce-a6af-4ff3-b8b9-5578d420600a
📥 Commits

Reviewing files that changed from the base of the PR and between 0c78c12 and 5b556a8.

📒 Files selected for processing: 3
  • gottext/CHANGELOG.md
  • gottext/src/pot.ts
  • gottext/test/build.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

messages and pot now filter extracted calls by the requested text domain. Calls without a domain are treated as default, while calls with a non-string domain argument are retained. Tests cover supported call forms and domain handling.

Changes: Gettext domain filtering

Layer / File(s) Summary
Define and apply domain filtering
gottext/src/pot.ts
Call-shape definitions identify message and domain arguments. Extraction keeps calls that match the requested domain and passes their messages to the parser.
Validate and document domain filtering
gottext/test/build.test.ts, gottext/CHANGELOG.md
Tests cover filtering in pot and messages, including default, concatenated string-literal, and non-string domains. The changelog records the filtering behavior and the default template option.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant messages
  participant extractorFor
  participant namesDomain
  participant parser
  messages->>extractorFor: Create extractors with call shapes and requested domain
  extractorFor->>namesDomain: Check call domain
  namesDomain-->>extractorFor: Return whether the call matches
  extractorFor->>parser: Pass messages from matching calls
Loading
Merge Risk: ⚪ Minimal · up to 5b556

No actionable issue remains in the supplied evidence; the change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: filtering extracted calls to retain only those that name the template's text domain.
Linked Issues check Passed Issue #100 requires domain filtering for __, _x, _n, and _nx calls. gottext/src/pot.ts now retains matching literal domains, treats calls without a domain as default, and retains non-strin…
Out of Scope Changes check Passed The changed source implements issue #100. The tests verify the required extraction behavior. The changelog documents the changed domain behavior and the required default configuration. No unrelated …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 …
Full details: Linked Issues check

Explanation

Issue #100 requires domain filtering for __, _x, _n, and _nx calls. gottext/src/pot.ts now retains matching literal domains, treats calls without a domain as default, and retains non-string domains. The change applies to messages and therefore to pot. Tests cover the four call shapes, default handling, other domains, concatenated literals, and non-string domains. The diff leaves Go markers and templates unchanged.

Full details: Out of Scope Changes check

Explanation

The changed source implements issue #100. The tests verify the required extraction behavior. The changelog documents the changed domain behavior and the required default configuration. No unrelated implementation or test changes are shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Absence of Expected Change Pattern

  • framework/gottext/test/build.test.ts is usually changed with: framework/gottext/src/gates.ts

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes are safe to merge: domain filtering behaved as described, and Go/template extraction remained unchanged.

Summary

This PR filters JavaScript translation calls by the template’s text domain.

  • Templates keep calls that name their requested text domain.

All 83 extraction/build tests passed. Independent public API checks also passed for all eight supported call variants, domain filtering, duplicate messages, and Go/template preservation. No blocking issues were found; the changes are safe to merge.

Reviews (1) · Last reviewed commit: "docs(gottext): note the text domain filt..." · Reviewed by Greptile

@SirLouen
SirLouen merged commit 65a973c into main Oct 18, 2026
41 checks passed
@SirLouen
SirLouen deleted the fix/100 branch October 18, 2026 17:36
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.

gottext: a template collects the messages of every text domain

1 participant