fix(i18n): bind block editor scripts to the text domain - #40
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Editor panels are built in JavaScript and translated by
@wordpress/i18n, which only resolves once the script handle is bound to the text domain viawp_set_script_translations(). Declaringwp-i18nas 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\Registrarnow binds every registered block'seditor_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:
roxyapi/*blockstextdomainon editor script handleNONEroxyapiGuarded by a new assertion in
test-block-registration.phpcovering 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.