-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenberg: Add i18n wrappers to provide the Jetpack textdomain #28088
Conversation
Note, we've been discussing (pa9srA-W-p2) using the /cc @akirk |
If this can be a quick change, that sounds good, but if it takes a while, FWIW it will be a blocker for shipping localized and translatable Jetpack blocks. |
Well, it seems that if we remove textdomain, we'll remove the possibility for I'll try with a different solution, likely with our wrappers for the |
Done, this is ready for another review. |
Placing it under [Pri] High as this needs to land soon to allow Jetpack blocks to be translatable. |
27aac77
to
7b0898d
Compare
Also, rebased. |
let's merge it! |
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.
Tested in Calypso-Gutenberg: works well apart from expected "Jed localization error: Error: Domain jetpack
was not found."
Tested in Jetpack-Gutenberg: works great, tested changing block title to "Settings" and I could see it translated to Finnish.
Tested exporting translation strings in Jetpack by npx gulp languages:extract
— I can see the script looking into block files but I didn't see it pick any strings to _inc/jetpack-strings.php
file in Jetpack. Was this expected?
Noting also that the build bundle fails in latest Jetpack master
and latest Gutenberg with some lodash
error, but that seems unrelated to this PR. I removed all the other blocks except Markdown from the preview and this worked great. 👍
Code looks great, clever idea!
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.
Tested exporting translation strings in Jetpack by
npx gulp languages:extract
— I can see the script looking into block files but I didn't see it pick any strings to_inc/jetpack-strings.php
file in Jetpack. Was this expected?
Tested again by building minified prod-versions by adding NODE_ENV=production
to SDK command and now extracting strings works like a charm. 👍
It seems we'll have to ditch the textdomain from the i18n function calls in our blocks for good. Reason: it messes with how
xgettext-js
parses the files.However, we need to still provide the textdomain so Gutenberg would be able to find the Jetpack translations where they are.
To address this, we provide wrappers for the wp.i18n functions that add the textdomain, and by this:
Changes proposed in this Pull Request
jetpack
textdomain from any Jetpack blocks in order to allow Jetpack to index the translations properly.Testing instructions