-
Notifications
You must be signed in to change notification settings - Fork 805
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
Adapt Jetpack to use WordPress JS i18n, fix Gutenberg block i18n. #11225
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: February 5, 2019. |
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.
I tried to test this, but could not get it to work. Maybe I did not test well.
- I seem to get the following error when I run
yarn build-languages
, afer deleting the existing language files inlanguages/json
to start from scratch.
./tools/msgexec-callback.sh: line 20: conditional binary operator expected
In the end, my jetpack-strings.php
file was empty for some reason. Should I have tested somehow differently?
- Should we clean up the 2 .pot files in the build folder to make sure they do not get shipped?
- Would there be a way for us not to commit all those json files, but instead only commit them on built branches?
Thanks for trying to test, the updated version should be testable for you because I made it compatible with older bash versions. The incompatibility was the reason why your Unfortunately, we'll have to commit the JSON files because they both change their name, and change their data format - existing Jetpack translations that are in master will not get picked up by the new system. |
…at as WordPress 5.0 and renames JSON files to be loaded into WP's i18n.
5ca50ea
to
f7e1614
Compare
It seems to work well for me now, and I like the approach of this. I have rebased the PR so it can be merged. @zinigor What would you think about deleting the pot files before shipping, with something like this: diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 5f7ee321a..c64537c73 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -196,6 +196,15 @@ gulp.task( 'languages:cleanup', function( done ) {
} );
done();
} );
+
+ log( 'Cleaning up POT files.' );
+ del( [
+ '_inc/build/blocks/*.pot',
+ './_inc/build/jetpack-strings.pot',
+ './_inc/build/merged-strings.pot',
+ ] ).then( function() {
+ done();
+ } );
}
);
} ); |
__( "SEO preview tools", "jetpack" ), // _inc/client/components/jetpack-disconnect-dialog/index.jsx:96 | ||
__( "Site stats, related content, and sharing tools", "jetpack" ), // _inc/client/components/jetpack-disconnect-dialog/index.jsx:103 | ||
__( "Brute force attack protection and downtime monitoring", "jetpack" ), // _inc/client/components/jetpack-disconnect-dialog/index.jsx:107 | ||
__( "Unlimited, high-spee |
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.
For some reason we seem to have less strings here now than in the old jetpack-strings.php
file:
https://github.com/Automattic/jetpack/blob/branch-7.0/_inc/jetpack-strings.php#L724
On my end, and that seems even weirder: if I run yarn build-languages
on this branch locally, my jetpack-strings.php
file only contains 633 lines.
What could explain all those differences?
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.
We have several strings in the old jetpack-strings.php file that are repeated several times, for example strings like "At A Glance" or "Connected" can be seen used two or three times. The new POT merging method using msgcat
merges these into entries that are only used once. I didn't compare the diff string by string, but I'm betting that this is the reason.
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.
This seems to work well. I'll merge, and put this to good use today :)
…1225) <!--- Provide a general summary of your changes in the Title above --> * Adapts JSON language files to be usable in WordPress client-side i18n. * Rebuilds JSON language files. * Adds a mechanism to integrate POT files that result from [block building](Automattic/wp-calypso#30303) into `jetpack-strings.php`. The whole PHP file generation pipeline now consists of one i18n-calypso run, one msgcat run, and one msgexec run that executes a bash script for every translation. * Paves the way for legacy i18n support and makes initial steps to move towards wp.i18n. Currently blocks don't have any strings translated yet in the JSON files because the strings themselves are not present in the code. After merging this code we should be able to re-run language builds and get translated strings in blocks. * Make sure the existing i18n works properly, including existing wp-admin Settings translations. * Adapted existing Jetpack translations to be used in WordPress i18n mechanisms. Co-authored-by: Jeremy Herve <[email protected]>
Cherry-picked to |
Here is the first run in the release branch: 0c16a17 It seems the strings from the blocks disappeared from the I did, however, notice this error during the run:
|
Changes proposed in this Pull Request:
jetpack-strings.php
. The whole PHP file generation pipeline now consists of one i18n-calypso run, one msgcat run, and one msgexec run that executes a bash script for every translation.Testing instructions:
Currently blocks don't have any strings translated yet in the JSON files because the strings themselves are not present in the code. After merging this code we should be able to re-run language builds and get translated strings in blocks.
Proposed changelog entry for your changes: