Repository navigation
fix(i18n): 64 translatable strings, and no way to deliver a translation - #54
Conversation
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
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 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. Themake-mo/make-jsonbranch 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
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
|
Both adversarial-review threads answered, one commit pushed as 1b82755. Both rebutted, both left open for you.
Lean gate green: 268 assertions, 0 failures, both render themes clean. The new gate fails once when the branch is neutered with a Not done: 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#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
Summary
languages/sahaj-atlas.pot, built in CI, so a translator has something to start from.Changes
sahaj-atlas.php—Domain Path: /languages, andsahaj_atlas_load_textdomain()called fromsahaj_atlas_init().includes/embed.php—wp_set_script_translations()for thesahaj-atlas-editorhandle.wp.i18nreads a.json, never the.mo..github/scripts/i18n.sh— new. Builds the.pot, and the.mo/.jsonfrom 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.pohaving its.mobeside it.tests/i18n.php— new suite, 9 assertions, both readers.Test results
pnpm test:all— syntax lane 12 files clean, measure lane 0 failures, behaviour suite 268 assertions / 0 failures, render lane (block + classic) 0 failures..github/scripts/package.sh . build— 134 files,sahaj-atlas/languages/sahaj-atlas.potpresent with 71 msgids. With a throwawayfr_FR.postaged: 137 files, the.moandsahaj-atlas-fr_FR-ea7506ee….jsonboth built, andmd5('blocks/embed/editor.js')is that same digest — the name core'sload_script_textdomain()asks for.Manual verification
.pofor a locale intolanguages/, 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.pohas gone throughi18n.shonly against a throwaway file, never a human-authored one.Notes for reviewer
Four judgement calls worth checking.
The POT is built, not committed.
wp i18n make-potstamps aPOT-Creation-Date, so a committed template conflicts on every branch. It is built insidepackage.sh, between staging and zipping, rather than inrelease.ymlas 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 thatpackage.shnow needs PHP onPATHand one outbound fetch; it fails loudly if either is missing, and both CI jobs run onubuntu-latest, which ships PHP.make-moandmake-jsonhave no input yet, and are gated anyway. They run only when a.poexists, so today they do not run in CI. The adversarial review asked whether that branch belongs before a.poexists. It does: dropping it would relocate the risk, not remove it, since PHP reads only the.moandwp.i18nonly the.json, so a.poshipped alone is a translation that silently stays English — the defect this PR fixes, re-entering through the build.package.shnow refuses a zip holding a.powith no.mo, which puts the branch under CI from the first committed.poonward. The thread is left open for the reviewer to settle.sahaj_atlas_load_textdomain()is a named function, where the ticket's step 2 putload_plugin_textdomain()inline. The seam is the test's:tests/i18n.php:119calls it afterunload_textdomain(), and inlining would make the suite re-typedirname( 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
.moand.json; nofr_FRfiles 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), theinitcall removed (1 red), theDomain Pathheader removed (1 red),i18n.shneutered (the zip gate red), themake-potexclude list narrowed (the string-count gate red, reporting 6), and themake-mo/make-jsonbranch short-circuited with afr_FR.postaged (the new.po/.mogate 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 fromsahaj_atlas_init().init told the registry where this plugin keeps its translationsreads the path the realinitrun 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):RUNNER_TEMPis fresh per job, so the cache could never have hit in CI anyway.make-pothad written that exact path twelve lines earlier..gitignorehides the fixtures..mofixture was packed by hand. Now core'sMOwriter, whichwp-settings.phprequires unconditionally — the class paired with the reader under test.docs/rules/code-comments.mdandtests/comment-fingerprint.phpcorrected (the 34.po/.mopairs are Plugin Update Checker's, not this plugin's).Findings dismissed, with reasons:
is_admin()to save work on front-end requests. It would break translation:includes/page.phpandincludes/shortcode.phpevaluate__()on the front end, 7 strings between them.languagesdirectory 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.make-json --no-purgebeforemake-moso the.modrops 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.i18n.shuntil a first.poexists. 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.powhose 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/.mogate asserts the.moalone: a translator who leaves the nineeditor.jsstrings untranslated would otherwise turn CI red for a legitimate file.Anomaly.
workflow/lib/comment-lint.mjsreports0 changed file(s)on this branch: itsEXTregex covers onlyts|tsx|js|jsx|mjs|cjs|mts|cts, so it cannot see a PHP or shell diff.finalize-pr/SKILL.mdsays 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