Closed yuliyan closed 3 months ago
Size Change: +2.8 kB (+1.42%)
Total Size: 200 kB
Filename | Size | Change |
---|---|---|
./build/index.js |
125 kB | +2.8 kB (+2.29%) |
Thank your for reviewing the changes, @ilyasfoo!
I'm sorry I didn't make the instructions more clear, but rendering the translated strings is a separate problem caused by using incorrect text domain (i.e. woocommerce
instead of wc-calypso-bridge
).
The goal of this PR is to load the translation data into the i18n instance, i.e. to make sure wc-calypso-bridge-js-translations
script is printed on the page.
I plan to follow up with creating a separate PR to update the text domain and another PR to commit translations files (i.e. run npm run prepare
).
@ilyasfoo,
I've previously mentioned that some gettext calls were using incorrect text , but after further looking into it, I've noticed that some of the strings also exist in WooCommerce and updating the text domain would it from re-using the WooCommerce translations.
Instead, I took a different approach and add fallback translation lookup for gettext calls with woocommerce
text domain that are missing tranaslations - https://github.com/Automattic/wc-calypso-bridge/pull/1472/commits/f1bceadbd63ad7006885325029e469a92f8c02bd. If you repeat your testing steps, you should now see the translated items.
I've also noticed that there were some lazy loaded modules that have their own translation files, that were previously not handled, so I've updated the PR to also handle this case in https://github.com/Automattic/wc-calypso-bridge/pull/1472/commits/9f81bc2882b65eaecebf8922bb6c1153c53e73ec.
Changes proposed in this Pull Request:
wc-calypso-bridge
script.wp i18n make-json [path-to-po-file]
./src
path when generating the POT file to reduce the number of JSON translation files generated withmake-json
, as it uses the files paths references in the POT file to create the JSON files. A JSON translation files is loaded when its corresponding JS is enqueued in WordPress and given that the source modules never enqueued directly, generating translation files for those is unnecessary.gettext
calls withwoocommerce
to attempt to translate the same string usingwc-calypso-bridge
when there's no translation in thewoocommerce
domain. This change is targeted at gettext call used in this package withwoocommerce
text domain (such as #1, #2, #3, etc.).Related to 799-gh-Automattic/i18n-issues
How to test the changes in this Pull Request:
wp i18n make-json languages/[language].po
./wp-admin/admin.php?page=wc-admin
and confirmwc-calypso-bridge-js-translations
translation data is loaded, i.e. the script<script id="wc-calypso-bridge-js-translations">
that loads the data usingwp.i18n.setLocaleData()
is printed on the page./wp-admin/admin.php?page=wc-admin&path=%2Fmarketing
and confirm translations for lazy loaded moduleMarketing
are loaded as expected. TheisEcommercePlan
,isEcommercePlanTrial
,isWooNavigationEnabled
params on your test site must betrue
(can be overridden in class-wc-calypso-bridge-shared.php)Other information:
FOR PR REVIEWER ONLY: