Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNA: allow updating textdomains in JS and PHP packages used in multiple plugins #20320

Closed
1 of 2 tasks
jeherve opened this issue Jul 9, 2021 · 1 comment
Closed
1 of 2 tasks
Labels
Build [Focus] i18n Internationalization / i18n, adaptation to different languages [Focus] Jetpack DNA [JS Package] Components [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Pri] Normal [Type] Task

Comments

@jeherve
Copy link
Member

jeherve commented Jul 9, 2021

Our PHP and JS packages currently use the jetpack textdomain for all translatable strings. While that's the right thing to do for all strings that are shipped with the Jetpack plugin, those strings will not be translated if they are shipped as is in other plugins with a different slug.

We should consequently consider automatically updating those textdomains on production versions of each plugin.

  • Update strings in JS packages
  • Update strings in PHP packages

@kbrown9 looked into the PHP part of this last year, in #18070, and offered a solution that was added to our docs:

### Package textdomains
Jetpack's packages use the 'jetpack' textdomain for translatable strings. Plugins that use these packages must change the textdomains in the packages when preparing the plugin for release. A few tools that can help automate this process are [node-wp-i18n](https://github.com/cedaro/node-wp-i18n) and [wp-textdomain](https://github.com/timelsass/wp-textdomain).
For example, a plugin could change the textdomain during the Composer `post-autoload-dump` event with the following script in the plugin's `composer.json` file:
`"post-autoload-dump": "node {path_to_script}/update_textdomain.js"`
where the `update_textdomain.js` file contains something like:
```
const wpTextdomain = require( 'wp-textdomain' );
wpTextdomain( './vendor/automattic/**/*.php', {
domain: 'plugin-textdomain',
fix: true,
glob: { follow: true },
} );
```

It may be time to start adding that solution to our monorepo plugin that consumes packages, the Backup plugin.


Related: #17099


Example use-case: Jetpack components (see #20287).

@jeherve jeherve added [Focus] i18n Internationalization / i18n, adaptation to different languages [Type] Task [Pri] Normal Build [Focus] Jetpack DNA [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [JS Package] Components labels Jul 9, 2021
@anomiex
Copy link
Contributor

anomiex commented Jan 5, 2023

I believe everything here has been done.

The JS part is done more or less as proposed here via the babel-plugin-replace-textdomain package, the domains are rewritten as the bundle is being produced.

For the PHP part, instead of rewriting packages when embedded into the plugins we did as described in #21690 (comment).

@anomiex anomiex closed this as completed Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build [Focus] i18n Internationalization / i18n, adaptation to different languages [Focus] Jetpack DNA [JS Package] Components [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Pri] Normal [Type] Task
Projects
None yet
Development

No branches or pull requests

2 participants