Skip to content

fix(i18n): bind block editor scripts to the text domain - #40

Merged
ph33nx merged 1 commit into
mainfrom
fix/block-editor-script-translations
Aug 5, 2026
Merged

fix(i18n): bind block editor scripts to the text domain#40
ph33nx merged 1 commit into
mainfrom
fix/block-editor-script-translations

Conversation

@ph33nx

@ph33nx ph33nx commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Editor panels are built in JavaScript and translated by @wordpress/i18n, which only resolves once the script handle is bound to the text domain via wp_set_script_translations(). Declaring wp-i18n as a script dependency is not enough on its own.

The failure is silent: the editor panel stays English while every PHP string on the same screen translates correctly.

Blocks\Registrar now binds every registered block's editor_script_handles. No path argument is passed, because wordpress.org builds and serves the JSON translation files for hosted plugins (per the WordPress handbook).

Verified

Against a live WordPress with the working tree mounted:

Check Before After
Registered roxyapi/* blocks 153 153
textdomain on editor script handle NONE roxyapi
Block editor console errors 0 0

Guarded by a new assertion in test-block-registration.php covering all 153 blocks, with a non-vacuity check so an empty registry cannot make it pass silently.

Verification note

phpcs, phpstan level 8 and prettier pass locally. phpunit and plugin-check need wp-env, which cannot start in that environment, so CI is the gate for those two.

Editor panels are built in JavaScript and translated by @wordpress/i18n, which
only resolves once the script handle is bound to the text domain. Declaring
wp-i18n as a dependency is not enough on its own, so the editor panels stayed
English while every PHP string on the same screen translated correctly.

Registrar now binds every registered block's editor_script_handles. No path
argument, because wordpress.org builds and serves the JSON translation files.

Guarded in test-block-registration.php across all 153 blocks.
@ph33nx
ph33nx merged commit cea271d into main Aug 5, 2026
11 checks passed
@ph33nx
ph33nx deleted the fix/block-editor-script-translations branch August 5, 2026 17:51
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