-
Notifications
You must be signed in to change notification settings - Fork 384
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
Eliminate obsolete i18n code #1789
Conversation
Gruntfile.js
Outdated
@@ -38,7 +38,8 @@ module.exports = function( grunt ) { | |||
command: 'npm run pot-to-php && php -l languages/amp-translations.php' | |||
}, | |||
makepot: { | |||
command: 'wp i18n make-pot . languages/amp-js.pot --include="*.js" --file-comment="*/null/*"' // The --file-comment is a temporary workaround for <https://github.com/ampproject/amp-wp/issues/1416>. | |||
// TODO: The exclude argument to make-pot does not seem to actually exclude. Without including the --exclude argument, the generated amp-js.pot still includes references to the build/ directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy Can you advise regarding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build
was never excluded by default, so if you don't need that, you have to pass --exclude
.
Note: The latest version of the command changed the way includes and excludes are handled based on scores, see wp-cli/i18n-command#104.
@felixarntz Does running |
Quick question: Does the plugin still support WordPress 4.9 with the Gutenberg plugin or is Gutenberg support aimed at WordPress 5.0 only? |
Support is intended for 4.9 without Gutenberg as well. For example #1781 |
WordPress.org should handle string extraction of JavaScript files by now, as you can see here: https://translate.wordpress.org/projects/wp-plugins/amp/dev/en-gb/default?filters%5Boriginal_id%5D=7004670 That also means WordPress.org ships language packs with JSON translation files in them since WordPress 5.0. So there's no need to manually build POT files anymore. Note: I published an in-depth guideline for WordPress JS I18N on my website: https://pascalbirchler.com/internationalization-in-wordpress-5-0/
|
@swissspidy ok, thank you. So we can eliminate So given this example: amp-wp/includes/admin/class-amp-editor-blocks.php Lines 162 to 171 in 8f7a60a
Are you saying that we don't need the Also, will |
Yep, there's no need for that anymore. WordPress.org handles the make-pot part nowadays.
4.9 + Gutenberg should still have
No :-) That's the whole point of this new function. Everything is split up into multiple little JSON files that will be read and passed to the JS libraries in your plugin. See https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/ for more info. However, You could shim |
@swissspidy thank you very much. I've amended the PR then to eliminate POT generation entirely. The result is that there is that there is no longer a |
WordPress no longer needs POT files or generated PHP files for translation strings to be discovered. So we can eliminate all of that code.
This PR also adds a missing
translators
comment.Without this--exclude
argument, runningtime lando grunt shell:makepot
takes 73 seconds to complete. What's more is that the generatedamp-js.pot
file includes references to files in thebuild/
directory even though this directory is not included in the--include
argument. When the--exclude
is included, the time to runtime lando grunt shell:makepot
cuts down to 41 seconds. Even though this is entirely too long to run (which is likely due to a Lando problem), it shows that adding the--exclude
is cutting down on processing files unnecessarily.This PR also uses Composer to explicitly mark thewp-cli/i18n-command
dependency with a pinned version.