-
Notifications
You must be signed in to change notification settings - Fork 799
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
I18n messages from Composer packages are never translated #21690
Comments
This issue will most likely block @Automattic/jetpack-search from moving forward with our code migration to the standalone package. Does @Automattic/jetpack-crew have an idea on when/if this issue will be addressed? For context, we're aiming to complete our code migration to the standalone package by the end of this month. cc @bluefuton |
Probably still a work around. Just a thought here, we could possibly publish the JS builds to |
Is the problem linked to the files in
If |
@anomiex Where do things stand on needing a dynamic textdomain (e.g. what textdomain is used for a package that is in both Jetpack-the-plugin and a standalone)? Whether or not |
On the WP CLI side, the default exclusion of If WP CLI does not want to entertain a change to the default, we could open a meta.trac ticket regarding .org including vendor (or perhaps having some way for a plugin to indicate to include vendor, or a specific folder string like |
Lastly, going back to how we did JS translations could work. On build, we make-pot ourselves, convert that to an array in PHP that has the plugin textdomain and include that. |
I was happy when we were able to move away from this towards core js translations, but I can see how useful it could be here. Such a system may allow us to address both this issue and #20320 at once, when building the production version of a plugin generated from the monorepo. |
Yeah, I really don't like having to go back to a homegrown solution, but given that the solutions otherwise are to get Core or WP CLI to move on something when we're looking at wanting something ready to go into prod at the end of month... I think homegrown may be the best way forward until the ecosystem (with our help) can have a solution. |
I'm supposed to be AFK today, but I was thinking about this anyway and had a few ideas.
Thoughts? Longer term, if we could get WordPress.org to change some of their infrastructure, something like this might make sense:
That way all we'd need to do would be to have the plugin declare the packages' text domains, and the translators would only have to translate each package's strings once instead of for every plugin using the package. |
Your ideas seem reasonable to me. Do you think there's any value in also investigating how the autoloader would need to be changed to allow composer to be configured to use something other than the default |
We could investigate it, but we shouldn't need to if my idea pans out. I suspect the best route if we did want to go in that direction would be to have it check for some specific non-vendor directory in addition to |
If we did need to go in this direction, I think we would need to have the autoloader write some files to the |
This script is the one expected by the default configuration of the new `@automattic/i18n-loader-webpack-plugin`. Note the `domainMap` is currently empty. Code to fill that in will come later, as part of #21690, once we figure out the exact form of it.
This script is the one expected by the default configuration of the new `@automattic/i18n-loader-webpack-plugin`. Note the `domainMap` is currently empty. Code to fill that in will come later, as part of #21690, once we figure out the exact form of it.
This script is the one expected by the default configuration of the new `@automattic/i18n-loader-webpack-plugin`. Note the `domainMap` is currently empty. Code to fill that in will come later, as part of #21690, once we figure out the exact form of it.
This adds the ability to register textdomain aliases with the Assets package. Assets then hooks into `__()` and so on to have them check the aliased-to domain if no translation is found for the aliased-from domain. It also hooks into script translation file loading to load a translation file for the aliased-to domain if no file exists for the aliased-from domain. This brings us one step closer to fixing #21690. Followups will switch all the packages to use alias-able textdomains (instead of them all using "jetpack") and arrange for the aliases to actually be registered.
This adds the ability to register textdomain aliases with the Assets package. Assets then hooks into `__()` and so on to have them check the aliased-to domain if no translation is found for the aliased-from domain. It also hooks into script translation file loading to load a translation file for the aliased-to domain if no file exists for the aliased-from domain. This brings us one step closer to fixing #21690. Followups will switch all the packages to use alias-able textdomains (instead of them all using "jetpack") and arrange for the aliases to actually be registered.
To finally fix #21690, we need each package to have its own textdomain and to declare that domain in its `composer.json`. The work done in previous PRs will take it from there: composer-plugin will include the packages' domains in the generated `i18n-map.php` (#22096), which the plugin will pass to the Assets package (#22143), which will map those package textdomains to the plugin's (#22083). This also adds checks to the monorepo linting script to help people get the setup right: * Packages may not use a textdomain that matches a plugin slug. * If the package's phpcs config or eslint config sets a textdomain (which it will have to if it uses i18n after #22117 and #22131), require that same textdomain is set in composer.json.
Impacted plugin
Jetpack, Backup, Boost
Steps to Reproduce
Easiest way to observe this at the moment is to compare the list of strings available for translation for the Backup plugin at https://translate.wordpress.org/projects/wp-plugins/jetpack-backup/dev/es/default/ with the strings that are present in packages/backup.
Or you could run
wp i18n make-pot
on one of the plugins and look more directly.A clear and concise description of what you expected to happen.
All the strings from the package are able to be translated, somehow.
What actually happened
Only the ones defined in the plugin itself can be translated.
Other information
The problem is that
wp i18n make-pot
ignoresvendor/
.There was some discussion at p1634933470116600-slack-CBG1CP4EN.
One idea would be to configure composer to use something other than
vendor/
for the plugins that bundlevendor/
. But it was said that this would need some work in the Jetpack Autoloader package.Another idea would be to somehow get the packages translated as standalone projects, and then either bundle the translations in the packages or somehow convince WordPress to download the packages' i18n data along with the plugin. There doesn't seem to be a straightforward way to do this at the moment.
Operating System
Other
OS Version
No response
Browser
Other / Not applicable
Browser Version(s)
No response
The text was updated successfully, but these errors were encountered: