Skip to content

fix(i18n): 64 translatable strings, and no way to deliver a translation - #54

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/fix-17-i18n-load-path
Oct 2, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/fix-17-i18n-load-path

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A translation installed in the plugin now loads. Before, nothing read one, so every admin string rendered in English in every locale.
  • The release zip carries languages/sahaj-atlas.pot, built in CI, so a translator has something to start from.
  • No translation ships. Per the request on the ticket, English only for now — this is the delivery path, not a translation.

Changes

  • sahaj-atlas.php — Domain Path: /languages, and sahaj_atlas_load_textdomain() called from sahaj_atlas_init().
  • includes/embed.php — wp_set_script_translations() for the sahaj-atlas-editor handle. wp.i18n reads a .json, never the .mo.
  • .github/scripts/i18n.sh — new. Builds the .pot, and the .mo/.json from any committed .po, into the staged plugin.
  • .github/scripts/package.sh — calls it between the rsync and the zip, then gates on the template's string count and on a staged .po having its .mo beside it.
  • tests/i18n.php — new suite, 9 assertions, both readers.

Test results

  • Lean gate: ✓ pnpm test:all — syntax lane 12 files clean, measure lane 0 failures, behaviour suite 268 assertions / 0 failures, render lane (block + classic) 0 failures.
  • Packaging: ✓ .github/scripts/package.sh . build — 134 files, sahaj-atlas/languages/sahaj-atlas.pot present with 71 msgids. With a throwaway fr_FR.po staged: 137 files, the .mo and sahaj-atlas-fr_FR-ea7506ee….json both built, and md5('blocks/embed/editor.js') is that same digest — the name core's load_script_textdomain() asks for.
  • Build: N/A — the plugin has no build step, and this PR does not add one.

Manual verification

  1. Install a .po for a locale into languages/, set the site language to it, and confirm the settings screen and the diagnostics panel render translated. The suite covers this with a generated .mo; a real translator's .po has gone through i18n.sh only against a throwaway file, never a human-authored one.
  2. Open the block inspector in that locale and confirm its controls are translated.

Notes for reviewer

Four judgement calls worth checking.

The POT is built, not committed. wp i18n make-pot stamps a POT-Creation-Date, so a committed template conflicts on every branch. It is built inside package.sh, between staging and zipping, rather than in release.yml as the ticket's step 4 proposed — that is the only placement where the zip a PR inspects and the zip a release publishes come off the same line. The cost is that package.sh now needs PHP on PATH and one outbound fetch; it fails loudly if either is missing, and both CI jobs run on ubuntu-latest, which ships PHP.

make-mo and make-json have no input yet, and are gated anyway. They run only when a .po exists, so today they do not run in CI. The adversarial review asked whether that branch belongs before a .po exists. It does: dropping it would relocate the risk, not remove it, since PHP reads only the .mo and wp.i18n only the .json, so a .po shipped alone is a translation that silently stays English — the defect this PR fixes, re-entering through the build. package.sh now refuses a zip holding a .po with no .mo, which puts the branch under CI from the first committed .po onward. The thread is left open for the reviewer to settle.

sahaj_atlas_load_textdomain() is a named function, where the ticket's step 2 put load_plugin_textdomain() inline. The seam is the test's: tests/i18n.php:119 calls it after unload_textdomain(), and inlining would make the suite re-type dirname( plugin_basename( SAHAJ_ATLAS_FILE ) ) . '/languages' — the one expression it exists to pin, and two spellings free to drift apart.

The acceptance criteria for a French render are covered by the suite, not by a shipped translation. Criteria 5 and 6 are asserted against a generated .mo and .json; no fr_FR files are in the diff.

Detail

Fail-once, per AGENTS.md. Each new assertion was watched failing against the real gap before the fix was restored: wp_set_script_translations() removed (4 red), the init call removed (1 red), the Domain Path header removed (1 red), i18n.sh neutered (the zip gate red), the make-pot exclude list narrowed (the string-count gate red, reporting 6), and the make-mo/make-json branch short-circuited with a fr_FR.po staged (the new .po/.mo gate red).

One assertion exists only to catch the wiring. The suite calls sahaj_atlas_load_textdomain() directly, so every other assertion would still pass with the call gone from sahaj_atlas_init(). init told the registry where this plugin keeps its translations reads the path the real init run registered — load_plugin_textdomain() registers its directory even when it finds no file for the current locale.

Review findings fixed (six lenses: /simplify × 4, /code-review high, /security-review):

  • The phar cache branch trusted an existing file, skipping the hash check — the one line that makes the pin mean anything. Now fetched and hashed every run; RUNNER_TEMP is fresh per job, so the cache could never have hit in CI anyway.
  • The zip gate asserted the POT's path but not its content, and could not fail — make-pot had written that exact path twelve lines earlier.
  • The test's cleanup ran only if the file reached its last line. Now a shutdown function registered before the first write: the Playground mounts the working tree, and .gitignore hides the fixtures.
  • The .mo fixture was packed by hand. Now core's MO writer, which wp-settings.php requires unconditionally — the class paired with the reader under test.
  • Four duplicated prose blocks trimmed; docs/rules/code-comments.md and tests/comment-fingerprint.php corrected (the 34 .po/.mo pairs are Plugin Update Checker's, not this plugin's).

Findings dismissed, with reasons:

  • Gate the textdomain load on is_admin() to save work on front-end requests. It would break translation: includes/page.php and includes/shortcode.php evaluate __() on the front end, 7 strings between them.
  • Add a constant for the languages directory name. It collapses 2 of 8 spellings, makes both call sites longer, and cannot reach the plugin header or the shell copies. The new suite pins both runtime spellings, which is the stronger guard.
  • Cache the phar, and move packaging off the test job's critical path. Real CI wins, but tuning beyond this ticket.
  • Flip make-json --no-purge before make-mo so the .mo drops JS-only strings. It would also rewrite the staged .po, so the file a translator downloads would differ from the one in the repo. A few hundred bytes is the better trade.
  • Defer i18n.sh until a first .po exists. Acceptance criterion 4 asks for the template in the zip, and a translator needs it before they can write a .po.

One note on make-json's input. It writes nothing for a .po whose references name no JS file, since there is no JS string to split out. That is expected, not a failure, and it is why the .po/.mo gate asserts the .mo alone: a translator who leaves the nine editor.js strings untranslated would otherwise turn CI red for a legitimate file.

Anomaly. workflow/lib/comment-lint.mjs reports 0 changed file(s) on this branch: its EXT regex covers only ts|tsx|js|jsx|mjs|cjs|mts|cts, so it cannot see a PHP or shell diff. finalize-pr/SKILL.md says the check "covers SahajAtlasWordpress, where no linter runs at all". The added comments were reviewed by hand instead.

Closes #17

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_018aSJjB5t28sC6vWJbgEK1K

claude added 5 commits October 1, 2026 21:52
Every admin string was wrapped for translation and none of them could be
translated. Nothing loaded a translation file, so all 60-odd strings
rendered in English in every locale and no file a volunteer could install
would change that.

`load_plugin_textdomain()` is what makes the registry look inside the
plugin at all. Without it only `WP_LANG_DIR/plugins/` is searched, where a
wordpress.org language pack would land — and this plugin ships from GitHub
Releases, so no pack ever arrives. It is called from `sahaj_atlas_init()`,
on `init`, which is where WordPress 6.7 requires it.

`wp_set_script_translations()` covers a second, independent reader.
`blocks/embed/editor.js` calls `wp.i18n.__()` nine times, and `wp.i18n`
reads a `.json` keyed on an md5 of the script's path, never the `.mo`. The
editor would have stayed English even with a working `.mo` installed.

`Domain Path` is the third piece, and the one that loads nothing by
itself: `wp i18n make-pot` and every translation platform read it to find
where the files belong.

Refs #17

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BfmKjT9zoAYWuvuKa4KsKn
Without a template there is nothing for a translator to start from, so
the loading machinery in the previous commit has no input.

`wp i18n make-pot` stamps a POT-Creation-Date, which makes a committed
template conflict on every branch, so the file is built rather than
committed. It is built into the staged copy of the plugin, between the
rsync and the zip, because that is the only placement where the zip CI
inspects on a PR and the zip a release publishes come off the same line.
`package.sh` now also fails if the template is missing from the listing.

`.po` is therefore the only translation file anyone commits here. The
script builds the `.mo` PHP reads and the `.json` files `wp.i18n` reads
from it at the same point; shipping one of those two without the other is
the defect this ticket is about, so neither is left to a later step.

The wp-cli phar is pinned to a version and checked against the SHA-256
wp-cli publishes beside the release asset. It runs on the path that pushes
an auto-update to every site running the plugin.

This is release tooling, not a plugin build step. The zip still installs
and runs with no npm and no node_modules.

Refs #17

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BfmKjT9zoAYWuvuKa4KsKn
The gap this ticket closes was invisible to every lane: the plugin
returned 200, the panel read correctly in English, and nothing went red
for a year.

`tests/i18n.php` installs a French `.mo` and the editor's `.json` into the
plugin's own `languages/` directory and asserts both readers find them.
The `.mo` is written byte by byte rather than committed, since `wp i18n
make-mo` is not available inside the Playground and the strings a reader
needs are the point.

One assertion covers the wiring rather than the function: it reads the
path `init` registered with the textdomain registry, because every other
assertion here calls the loader directly and so would pass with the call
gone from `sahaj_atlas_init()`.

Each assertion was watched failing against the real gap before the fix was
restored — removing `wp_set_script_translations()`, the `init` call, and
the `Domain Path` header in turn, and neutering the POT step to confirm
the zip check.

`is_textdomain_loaded()` is deliberately not used: it reads the legacy
`$l10n` array, which WordPress 6.5's translation controller no longer
fills, so it answers false for a file it has just read.

Refs #17

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BfmKjT9zoAYWuvuKa4KsKn
Four, each raised by two or more lenses.

The wp-cli phar is fetched and hashed on every run. The old cache branch
trusted an existing file, so the one line that makes the pin mean anything
was the line a cache hit skipped — and `RUNNER_TEMP` is fresh per job, so
the branch could never have hit in CI.

`package.sh` now counts the template's strings instead of only asserting
its path. The old check could not fail: `make-pot` had written that exact
path twelve lines earlier. A `make-pot` narrowed by a stray `--exclude`
writes a valid template holding nothing but the plugin headers, which is
the defect #17 was about, and it would have shipped green. Verified by
narrowing the exclude list and watching the gate report 6 strings.

The test's fixture cleanup is a shutdown function registered before the
first write. The Playground mounts the working tree as the plugin
directory, and `.gitignore` now hides the fixtures, so a fatal mid-file
would have left a two-string fake French translation for the next local
`package.sh` run to ship.

The test builds its `.mo` with core's own `MO` writer instead of packing
the offset tables by hand. `wp-settings.php` requires `pomo/mo.php`
unconditionally, so the class writing the fixture is the one paired with
the reader under test — and principle 1 asks for the core API.

Refs #17

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BfmKjT9zoAYWuvuKa4KsKn
Both copies of the rule said an orphaned `translators:` comment "drops the
context for all 34 locales". The 34 `.po`/`.mo` pairs in the tree are
Plugin Update Checker's, under its own text domain; this plugin had none,
and still ships none. What the comment actually feeds is
`languages/sahaj-atlas.pot`, which is the only context a translator ever
gets.

The counts beside it were stale too: 15 `translators:` comments, not 9,
and 24 `@package SahajAtlas` headers, not 22.

Refs #17

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BfmKjT9zoAYWuvuKa4KsKn
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 1, 2026
@sydevs-bot

sydevs-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 22:26Z address-review · attempt 1 · session · done
  • 22:26Z address-review · attempt 1 · session
  • 22:15Z adversarial-review · attempt 1 · session · done
  • 22:15Z adversarial-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff matches the ticket — 10 files, 270 lines. I rebuilt the pipeline and it works end to end. Building the POT in package.sh beats the ticket's step 4: I reproduced the silent failure the count gate catches, an empty staged copy yielding a valid POT with one msgid.

Outside the diff: securityReview.triggerPattern names package.sh but not the new i18n.sh, so a later PR moving the phar pin skips security review. Fixing it needs an attended run, since .claude/ is protected.

Findings

  • should-fix — i18n.sh:53. The make-mo/make-json branch cannot run yet.
  • consider — sahaj-atlas.php:108. A one-line wrapper with one production caller.

What was checked

#17 and its comments. Read whole: both changed PHP files, block.json, tests/i18n.php, .distignore, both workflows. Built the POT from a staged copy: 71 msgids, 9 editor.js refs, 2 block.json refs. The pinned wp-cli SHA-256 matches the published one. register_block_type() runs after the textdomain load, so block.json's two strings translate.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread .github/scripts/i18n.sh Resolved
Comment thread sahaj-atlas.php Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 1, 2026
sydevs-bot and others added 2 commits October 1, 2026 22:31
The adversarial review asked whether i18n.sh's make-mo/make-json branch
belongs before a .po exists, since CI never executes it. It does belong,
and this is what puts it under CI.

A .po is the one translation file anyone commits, and the one file
neither reader can use: load_plugin_textdomain() reads the .mo, wp.i18n
reads the .json. So dropping the branch would not remove a risk, it
would relocate it — the first committed .po would ship as an inert file
and every string would stay English, with nothing failing. That is the
defect #17 fixed, re-entering through the build.

The gate no-ops today and switches on with the first .po, which is the
same input the branch waits for. Verified against a throwaway fr_FR.po:
make-json writes sahaj-atlas-fr_FR-ea7506ee....json, and
md5('blocks/embed/editor.js') is that same digest, so the name is the
one core's load_script_textdomain() asks for. Neutering the branch with
the .po staged turns the gate red, which is the fail-once.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018aSJjB5t28sC6vWJbgEK1K
Whoever hits the red CI needs to know which check it is and why it
exists, not just that a .po alone is wrong.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018aSJjB5t28sC6vWJbgEK1K
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both adversarial-review threads answered, one commit pushed as 1b82755. Both rebutted, both left open for you.

  • i18n.sh:53 — the branch cannot run yet. Kept, and put under CI instead. Dropping it relocates the risk: PHP reads only the .mo and wp.i18n only the .json, so the first committed .po would ship inert with nothing failing. package.sh now refuses a zip holding a .po with no .mo (0ca84f4).
  • sahaj-atlas.php:108 — a one-line wrapper. Kept. tests/i18n.php:119 calls it after unload_textdomain(), and inlining makes the suite re-type the path it exists to pin. The body explains the deviation.

Lean gate green: 268 assertions, 0 failures, both render themes clean. The new gate fails once when the branch is neutered with a .po staged.

Not done: securityReview.triggerPattern still omits i18n.sh. It sits under .claude/, a protected path, so it needs an attended run.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 1, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 1, 2026 22:40
@sydevs-bot
sydevs-bot requested a review from Ardnived October 1, 2026 22:40
@sydevs-bot
sydevs-bot enabled auto-merge October 1, 2026 22:40
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit d601947 Oct 2, 2026
45 of 47 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-17-i18n-load-path branch October 2, 2026 00:26
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Oct 2, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 2, 2026
#54 and this branch each appended a trap numbered 24 to AGENTS.md. The
i18n trap keeps 24, the number already on main, and the sitemap trap
becomes 25.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01S3FoZd9LTWqERDq4qh5ZUf
@Ardnived Ardnived mentioned this pull request Oct 2, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(i18n): 64 translatable strings, and no way to deliver a translation

3 participants