-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add Jetpack and Layout Grid translations #4359
Conversation
"makepot:android:gutenberg": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-android.pot", | ||
"makepot:android:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./jetpack.pot --ignore-domain jetpack-android.pot", | ||
"makepot:android:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./layout-grid.pot --ignore-domain layout-grid-android.pot", | ||
"makepot:ios:gutenberg": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-ios.pot", | ||
"makepot:ios:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./jetpack.pot --ignore-domain jetpack-ios.pot", | ||
"makepot:ios:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./layout-grid.pot --ignore-domain layout-grid-ios.pot", |
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.
Generate POT files for each plugin including Gutenberg. This approach won't scale easily as we add more plugins, so I'll provide in a new PR a way to unify the POT files creation in a single command.
"makepot:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/*,*.native.js,*.ios.js,*.android.js,bundle/* --ignore-domain jetpack.pot", | ||
"makepot:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/*,*.native.js,*.ios.js,*.android.js,bundle/* --ignore-domain layout-grid.pot", |
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.
Similar to Gutenberg, we need to generate these POT files for each plugin to subtract strings on makepot:<platform>:<plugin>
above commands.
"genstrings:android": "npm run makepot:android:gutenberg && npm run makepot:android:jetpack && npm run makepot:android:layout-grid && ./bin/po2android.js bundle/android/strings.xml gutenberg-android.pot jetpack-android.pot layout-grid-android.pot", | ||
"genstrings:ios": "npm run makepot:ios:gutenberg && npm run makepot:ios:jetpack && npm run makepot:ios:layout-grid && ./bin/po2swift.js bundle/ios/GutenbergNativeTranslations.swift gutenberg-ios.pot jetpack-ios.pot layout-grid-ios.pot", |
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.
As we do for Gutenberg, we have also to include the POT files generated for each plugin (Jetpack + Layout Grid) when generating the localization strings files.
const potFilesContent = potFiles.map( (file) => fs.readFileSync( file ) ); | ||
const xmlOutput = po2Android( potFilesContent ); |
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.
Now the po2android
and po2ios
scripts support multiple POT files, they basically merge all strings into a single object that is later on used for generating the localization strings files.
gutenberg-mobile/bin/po2android.js
Line 87 in b42efc1
return { ...result, ...po.translations[ '' ] }; |
|
||
export default function setupBlockExperiments( capabilities ) { | ||
const LAYOUT_GRID_LOCALE_DOMAIN = 'layout-grid'; |
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.
The domain for the Layout Grid block is layout-grid
, here you can see an example.
@@ -26,6 +28,8 @@ const supportedJetpackBlocks = { | |||
}, | |||
}; | |||
|
|||
const JETPACK_LOCALE_DOMAIN = 'jetpack'; |
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.
The domain for Jetpack is jetpack
, here you can see an example.
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
I've got a bit of a task backlog right now, so I won't be able to get to this until next week. Could you take a look at this @jhnstn ? |
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.
Fixes #2615
Description
This PR adds the translation files for localizing Jetpack blocks and the Layout Grid block (block experiments).
I'd like to note that, although this PR adds the missing translations, it's only the first part of the process of the incorporation process, as these changes don't bring the logic for updating them.
Translation files
For this purpose, a new folder located at
src/i18n-translations
has been created and contains the translations for each project. These files have been generated as part of a different PR (#4366), where optimized translation files will be produced including only the strings used by the native version of the editor.NOTE: In the future, this folder won't be necessary as translations will be generated on the fly via a new command and when producing the JS bundle.
POT files
For the strings that are not part of the web version and therefore not included in the plugin's GlotPress project, we have to include them in the localization strings files (
bundle/ios/GutenbergNativeTranslations.swift
/bundle/android/strings.xml
), exactly the same as we do for the Gutenberg strings.This implied adding new NPM commands to generate the required POT files and updating the scripts we use for generating the localization strings files (
po2swift.js
/po2android.js
), so they support multiple POT files as now we'll have one file each Gutenberg, Jetpack, and Layout Grid projects.NOTE: I'm working on a new command to unify the POT files generation into a single one, so eventually, we won't need to add extra commands when adding translations of new plugins.
Localization strings files
The strings added to
bundle/ios/GutenbergNativeTranslations.swift
andbundle/android/strings.xml
files are strings coming from Jetpack and Layout Grid plugins that require translation as they're only referenced in.native.js
files.To test
Verify that localization strings files are not modified
npm run genstrings
bundle/ios/GutenbergNativeTranslations.swift
andbundle/android/strings.xml
are modified.Verify that Jetpack translations are present
bundle/ios/GutenbergNativeTranslations.swift
/bundle/android/strings.xml
).Verify that Layout Grid translations are present
bundle/ios/GutenbergNativeTranslations.swift
/bundle/android/strings.xml
).NOTE: I noticed that some strings of the Layout Grid block are not translated, looks like this is caused because they're not retrieved by the correct domain (reference) hence, they're not being included in the GlotPress project. We'll address this in a separate PR.
Click here to display screenshot
PR submission checklist: