Skip to content

fix(i18n): include built JS strings in the POT and load script translations - #98

Open
Adi-ty wants to merge 1 commit into
mainfrom
fix/i18n-js-strings
Open

Adi-ty wants to merge 1 commit into
mainfrom
fix/i18n-js-strings

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Description

JS strings now reach the translation template, and the plugin's own scripts load their JS translations.

Technical Details

  • npm run pot builds the production assets first (prepot), and composer pot scans all of assets/build instead of only assets/build/blocks, so strings from the src/js entries reach the POT.
  • The main, admin and editor scripts register through Assets::register_translated_script(). It calls wp_set_script_translations() with the plugin's languages/ path only when the build lists wp-i18n as a dependency, so a script without strings does not pull wp-i18n onto the page.
  • Block scripts get their textdomain from block.json. From WordPress 6.9, core finds their JSON in the path load_plugin_textdomain() registers; on 6.7 and 6.8 it only looks in wp-content/languages/plugins/, which the developer guide now notes.
  • Script modules are unchanged: the locked @wordpress/dependency-extraction-webpack-plugin 7.1.0 rejects @wordpress/i18n imports in modules.

Checklist

  • AssetsTranslationsTest registers through the public register_editor_assets() with a built fixture and a JSON file named the way wp i18n make-json names it. The translated string loads when the build lists wp-i18n, and nothing loads when it does not.
  • PHPUnit passes in wp-env (WordPress 7.1.5).
  • PHPCS, PHPStan and lint:package-json pass.

Screenshots

N/A.

To-do

  • Drop the WordPress 6.7 and 6.8 note from docs/local-development.md once the minimum is 6.9.

Fixes/Covers issue

N/A.

@Adi-ty
Adi-ty marked this pull request as ready for review November 19, 2026 21:20
Copilot AI balanced review requested due to automatic review settings November 19, 2026 21:20

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

2 participants