Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

The translation of block.json text doesn't fallback to WooCommerce's translations #8639

Closed
DAnn2012 opened this issue Mar 5, 2023 · 14 comments
Labels
focus: blocks Specific work involving or impacting how blocks behave. focus: i18n The issue/PR is related to internationalization. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning).

Comments

@DAnn2012
Copy link
Contributor

DAnn2012 commented Mar 5, 2023

Describe the bug

Title and description of some blocks does not display translated.

It concerns the following blocks:

  • All Products
  • Customer Account
  • Featured Category
  • Featured Product
  • Filter Block
  • Hand-picked Products
  • Best Selling Products
  • Product Categories List
  • Products by Category
  • Products by Tag
  • Products by Attribute
  • Checkout

Some findings

After a thorough investigation by @nielslange (see p1678281263182499-slack-C02UBB1EPEF), we believe that the translation of the text from block.json files sent to the back-end doesn't fallback to WooCommerce translations. In this particular case, the Italian translations of the text and description of our Blocks can be found in /wp-content/languages/plugins/woocommerce-it_IT.po, while the Woo Blocks file is missing (i.e., app/public/wp-content/languages/plugins/woo-gutenberg-products-block-it_IT.po).

Screenshots

image

woocommerce-blocks

Environment

WordPress (please complete the following information):

  • WordPress version: 6.1.1
  • WooCommerce version: 7.4.1 (even after updating to 7.5.0 - 7.5.1)
  • WooCommerce Blocks version: 9.4.4 (even after updating to version 9.6.5 - 9.6.6) included in WooCommerce
  • Site language: Italian

Desktop (please complete the following information):

  • OS: macOS
  • Browser Safari
  • Version 16.3 (17614.4.6.11.6, 17614)
@DAnn2012 DAnn2012 added the type: bug The issue/PR concerns a confirmed bug. label Mar 5, 2023
@DAnn2012 DAnn2012 changed the title Name and description of some blocks does not display translated Title and description of some blocks does not display translated Mar 6, 2023
@tarhi-saad tarhi-saad added focus: i18n The issue/PR is related to internationalization. focus: blocks Specific work involving or impacting how blocks behave. labels Mar 7, 2023
@tarhi-saad
Copy link
Contributor

tarhi-saad commented Mar 10, 2023

I updated the title and description highlighting some findings!

@tarhi-saad tarhi-saad added the type: cooldown Things that are queued for a cooldown period (assists with planning). label Mar 10, 2023
@tarhi-saad tarhi-saad changed the title Title and description of some blocks does not display translated The translation of block.json text doesn't fallback to WooCommerce's translations Mar 10, 2023
@DAnn2012
Copy link
Contributor Author

Hi @tarhi-saad

I thank you for your reply.

I noticed that the problem also occurs with inner blocks such as "Subtotal" of "Cart":

subtotal-cart

The problem seems similar to that addressed in these PRs: #8591 and #6737

There are i18n problems with the registerBlockType function from the wp-blocks package and problems with importing title and description in metadata from block.json files for some blocks and some inner blocks.

Thanks.

@nielslange
Copy link
Member

Hello @DAnn2012 👋

I noticed that the problem also occurs with inner blocks such as "Subtotal" of "Cart":

That's correct. Every element, that gets the title and description purely from the block.json will show the same problem. I also looked into this issue and while we do have a fallback mechanism in place that loads translations of PHP and JS/TS files from WooCommerce, in case WooCommerce Blocks does not have a corresponding translation, this fallback mechanism does to work for block.json files.

If you head over to https://translate.wordpress.org/locale/it/default/wp-plugins/woo-gutenberg-products-block/, you'll find the Italian translations there. Above the table, that shows the translation status, the following message can be found:

Translations for the readme are published almost immediately. The initial language pack for the plugin will be generated when 90% of the Stable (latest release) sub-project strings have been translated (currently 61%).

I also see that most strings have been translated, but haven't been approved yet. I'll reach out to my Italian-speaking colleagues to clarify if one of them can review and approve the waiting translations, so that the Italian language pack can be generated.

@DAnn2012
Copy link
Contributor Author

DAnn2012 commented Mar 14, 2023

Hello @nielslange

I thank you for your reply.

Unfortunately, I am familiar with how late strings are approved on translate.wordpress.org. I was the one who submitted for approval 826 828* strings in Italian from WooCommerce Blocks (which are already present and approved in WooCommerce), of which 538 539* for the stable release, but of these 233 are still awaiting approval, as you may have already seen from the link you sent me.

I would like to ask you something. But when the language package of WooCommerce Blocks for Italian language is generated, will it be automatically loaded and installed by WordPress even if my version of WooCommerce Blocks is the one included in WooCommerce?

Thanks.

(*) The number changed after today's release of version 9.8.0

@nielslange
Copy link
Member

Hello @DAnn2012,

Unfortunately, I am familiar with how late strings are approved on translate.wordpress.org. I was the one who submitted for approval 826 828* strings in Italian from WooCommerce Blocks (which are already present and approved in WooCommerce), of which 538 539* for the stable release, but of these 233 are still awaiting approval, as you may have already seen from the link you sent me.

I reached out to a few colleagues internally asking them if they could request PTE (Project Translation Editor) rights to be able to approve the waiting strings. I hope that they will be approved soon.

I would like to ask you something. But when the language package of WooCommerce Blocks for Italian language is generated, will it be automatically loaded and installed by WordPress even if my version of WooCommerce Blocks is the one included in WooCommerce?

Once the Italian language pack is generated, you might see an update prompt within the WordPress admin dashboard:

Screenshot 2023-03-14 at 19 55 00

@DAnn2012
Copy link
Contributor Author

DAnn2012 commented Mar 15, 2023

Hello @nielslange

I noticed that in the block.json files of the blocks and inner blocks that there are in the version of WooCommerce Blocks included in WooCommerce (see for example)

https://plugins.trac.wordpress.org/browser/woocommerce/tags/7.5.0/packages/woocommerce-blocks/build/all-products/block.json#L4

https://plugins.trac.wordpress.org/browser/woocommerce/tags/7.5.0/packages/woocommerce-blocks/build/inner-blocks/checkout-totals-block/block.json#L30

https://plugins.trac.wordpress.org/browser/woocommerce/tags/7.5.0/packages/woocommerce-blocks/build/product-tag/block.json#L76

the textdomain is set to woo-gutenberg-products-block, if I change it to woocommerce I get the translated strings displayed:

woob1

woob2

woob3

Could this be the problem? That is, when WooCommerce Blocks is included in WooCommerce the value of textdomain in the block.json files should be changed, as is done here for PHP and JS files:

https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/bin/package-update-textdomain.js

https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/bin/package-update.sh

Thank you.

@nielslange
Copy link
Member

Hello @DAnn2012,

Could this be the problem? That is, when WooCommerce Blocks is included in WooCommerce the value of textdomain in the block.json files should be changed, as is done here for PHP and JS files:

That's a great finding! Earlier today, I created Replace woocommerce-blocks textdomain in *.json files for the WooCommerce repo. I'll reach out to the folks and ask them to consider this change for the WooCommerce 7.6.0 release.

Meanwhile, you could search and replace woo-gutenberg-products-block with woocommerce directly within the WooCommerce plugin. Usually, I would not advise doing that, as your changes will be overwritten with the next release. That said, if the folks from WooCommerce consider the change for the next release, then you will not see a difference on your end.

Thanks again for pointing this out! Your comment helped a lot. 🙏

@DAnn2012
Copy link
Contributor Author

Hello @nielslange

I am very glad to have been helpful.

I just wanted to point out that in your screenshot that you posted in the PR the "Customer account" item is still in English. How come?

Your screenshot My screenshot
woob-ac2 woob-ac1

Thanks.

@nielslange
Copy link
Member

Hello @DAnn2012,

I just wanted to point out that in your screenshot that you posted in the PR the "Customer account" item is still in English. How come?

When comparing the WooCommerce Blocks translations with the WooCommerce translations, I noticed that the string Customer account appears twice in WooCommerce Blocks, but only once in WooCommerce. Unfortunately, I don't have an explanation at this time of what might be causing this problem.

However, it seems that as soon as the Italian language file for WooCommerce Blocks can be generated, the string Customer account should appear in Italian. An example can be seen when looking at the Dutch translation file. It currently has a translation status of 100%. The string Customer account had fully been translated and within the block inserter, the block title appears in Dutch.

Screenshot 2023-03-17 at 11 34 12

As for the Italian translation pack, my colleague requested permissions to be able to approve the waiting Italian translations. I hope that he'll find the time to approve the waiting strings within the next week.

@DAnn2012
Copy link
Contributor Author

DAnn2012 commented Mar 17, 2023

Hello @nielslange

However, if you notice, for WooCommerce Blocks the first string refers to the customer-account.js file in build/:

woob-dutch1

while the second string refers to two block.json files, one in build/customer-account/ and the other in assets/js/blocks/customer-account/:

woob-dutch2

While for WooCommerce the only string is for the two block.json files:

wooc-dutch

and it is also translated differently, the ones in your screenshot therefore seem to be from the WooCommerce Blocks translation and not the WooCommerce one.

In fact, only the WooCommerce Blocks customer-account.js file has, towards the end, this:

title:Object(i.__)("Customer account","woo-gutenberg-products-block")

concerning the registerBlockVariation, while this is not there in WooCommerce's customer-account.js file.

The strange thing is that to me, who changed only the textdomain reference from "woo-gutenberg-products-block" to "wordpress" in the wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/customer-account/block.json file, this does not occur and the translation is correct.

I also checked in my woocommerce-it_IT-596555b85aaacaedd61d314084752023.json file (which references the strings in the packages/woocommerce-blocks/build/customer-account.js file) and the string "Customer account" is not there, so to me it is taken from the woocommerce-it_IT.mo file

@nielslange
Copy link
Member

Hallo @DAnn2012,

I agree with your points and noticed the same. At this stage, unfortunately I do not have an answer what happened in this particular case.

@mikejolley
Copy link
Member

@nielslange the core .json change was merged; can this issue be closed now?

@tarhi-saad
Copy link
Contributor

@mikejolley, @nielslange! Is the translation fallback also supposed to work when using the Woo Blocks plugin? For now, this PR fixes the translation bug only when using Woo Blocks in core!

@nielslange
Copy link
Member

@nielslange the core .json change was merged; can this issue be closed now?

@mikejolley Initially, I thought about keeping this issue open until woocommerce/woocommerce#37234 had been shipped. However, I noticed that the change will be shipped with WooCommerce 7.7. Thus, it might not be available before the end of May. Therefore, I think it's safe to close this issue.

@mikejolley, @nielslange! Is the translation fallback also supposed to work when using the Woo Blocks plugin? For now, woocommerce/woocommerce#37234 fixes the translation bug only when using Woo Blocks in core!

@tarhi-saad While we are using a fallback mechanism for loading translations in JS and PHP files, for loading translations in JSON files, we don't have a fallback mechanism yet. My PR wasn't aiming at creating a fallback mechanism, but to ensure that the textdomain within JSON files will be changed from woo-gutenberg-products-block to woocommerce when WooCommerce Blocks get merged into core.

Back to your questions, when using both WooCommerce and WooCommerce Blocks, WooCommerce contains a translation of the JSON file, but WooCommerce Blocks does not contain a file, then the English string will be displayed.

Screenshot 2023-03-30 at 13 53 04

It is worth noting that the screenshot in the upper-left corner still shows Customer Account in English instead of in Italian. @DAnn2012 mentioned this in #8639 (comment). Personally, I cannot explain this issue, as I'm able to see a Dutch and German translation, but not the Italian translation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: blocks Specific work involving or impacting how blocks behave. focus: i18n The issue/PR is related to internationalization. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning).
Projects
None yet
Development

No branches or pull requests

4 participants