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

Editor side translations are loaded on the frontend side #6530

Closed
gigitux opened this issue Jun 7, 2022 · 12 comments
Closed

Editor side translations are loaded on the frontend side #6530

gigitux opened this issue Jun 7, 2022 · 12 comments
Assignees
Labels
focus: i18n The issue/PR is related to internationalization. focus: performance The issue/PR is related to performance. type: bug The issue/PR concerns a confirmed bug.

Comments

@gigitux
Copy link
Contributor

gigitux commented Jun 7, 2022

Describe the bug

On the frontend side, the code loads the block translations that belong to the editor side.

To reproduce

Steps to reproduce the behavior:

  1. Change the language to the Netherlands then update all translations.
  2. Create a page with the All Products block.
  3. Check the page source of the new page and you can notice that the editor side translations are loaded.

Expected behavior

The editor side translations should be loaded only on the editor side.

Screenshots

image

@gigitux gigitux added the type: bug The issue/PR concerns a confirmed bug. label Jun 7, 2022
@Aljullu
Copy link
Contributor

Aljullu commented Jun 9, 2022

@gigitux I think these translations come from wp-block-editor, right? In that case, do you think this is a duplicate of #4543?

@gigitux
Copy link
Contributor Author

gigitux commented Jun 9, 2022

@gigitux I think these translations come from wp-block-editor, right? In that case, do you think this is a duplicate of #4543?

Mmm, yes, more or less :D
The main problem is that this issue is not related only to the All Products block. I tried with Checkout block and we load the editor-side translation on the frontend side.

Maybe we should merge the issues and be sure that we check the problem for all blocks.

@Aljullu
Copy link
Contributor

Aljullu commented Jun 10, 2022

Can you check if that happens on npm run build instead of npm start (it doesn't for me 🤔 )? We do some more aggressive tree shaking on build, so some dependencies which are loaded in dev mode aren't in production.

@gigitux
Copy link
Contributor Author

gigitux commented Jun 13, 2022

Can you check if that happens on npm run build instead of npm start (it doesn't for me 🤔 )? We do some more aggressive tree shaking on build, so some dependencies which are loaded in dev mode aren't in production.

I installed the plugin from wp.org and I'm still able to reproduce the problem

@Aljullu
Copy link
Contributor

Aljullu commented Jun 13, 2022

I installed the plugin from wp.org and I'm still able to reproduce the problem

With the Checkout block? I tested again with this test site and I can't reproduce it:

https://ephemeral-aljullu-20220607.atomicsites.blog/checkout/ (← you will need to add a product to the cart for the Checkout page to appear)

I checked the source code of the page and can't find the wp-block-editor-js-translations string. Am I doing something wrong? 😕

Versions:

  • WooCommerce 6.5.1
  • WooCommerce Blocks 7.8.0
  • WordPress 6.0

@gigitux
Copy link
Contributor Author

gigitux commented Jun 13, 2022

I guess that you are not able to reproduce it because you have to switch to another language (for example switch to Italian).

On my test website, I'm able to reproduce the issue with the Checkout block.

I added a Checkout Block without adding shipping options and this is the Italian translation on the editor side:

image

This is the Checkout Block on the frontend side:
image

You can notice that the translations that I highlight on the first image don't appear, but unfortunately, it is loaded on our page:

image

In this case, the translations are added with a script tag with id wc-checkout-block-frontend-js-before.

@Aljullu
Copy link
Contributor

Aljullu commented Jun 13, 2022

I guess that you are not able to reproduce it because you have to switch to another language (for example switch to Italian).

Ouch, sorry, I forgot to change the language. 🤦‍♂️

In this case, the translations are added with a script tag with id wc-checkout-block-frontend-js-before.

Right, I'm able to see. I wonder if we should have two different issues, one for the All Products block (which I think is #4543) and one for the Checkout block (maybe this one?). I think they are two different issues and this way we can assign each one to the correct team. Thoughts? 🤔

@gigitux
Copy link
Contributor Author

gigitux commented Jun 13, 2022

I guess that you are not able to reproduce it because you have to switch to another language (for example switch to Italian).

Ouch, sorry, I forgot to change the language. 🤦‍♂️

In this case, the translations are added with a script tag with id wc-checkout-block-frontend-js-before.

Right, I'm able to see. I wonder if we should have two different issues, one for the All Products block (which I think is #4543) and one for the Checkout block (maybe this one?). I think they are two different issues and this way we can assign each one to the correct team. Thoughts? 🤔

I'm not sure because my knowledge of translations is pretty limited. I'm wondering:

  • Can we improve how we handle translations? Potentially not handling translations for each block, but create a code that works that we can easily re-use (maybe improve this)
  • Are there other blocks that we should check?

@Aljullu
Copy link
Contributor

Aljullu commented Jun 15, 2022

  • Can we improve how we handle translations? Potentially not handling translations for each block, but create a code that works that we can easily re-use (maybe improve this)

I have you some ideas on how to improve it, go for it! Maybe as a cooldown task?

  • Are there other blocks that we should check?

I'm not sure, I guess we could check all blocks, but those issues seem to be specific to Checkout and All Products, no?

@gigitux
Copy link
Contributor Author

gigitux commented Jun 16, 2022

I have you some ideas on how to improve it, go for it! Maybe as a cooldown task?

To be honest, for now, I don't have any ideas :(

I'm not sure, I guess we could check all blocks, but those issues seem to be specific to Checkout and All Products, no?

True, but in the case of the All products block, in the dedicated class there isn't any particular code for the translations.

This is the reason why I think that we should debug this code on the AbstractBlock class.

@nielslange nielslange added the focus: i18n The issue/PR is related to internationalization. label Jul 12, 2022
@Aljullu Aljullu added the focus: performance The issue/PR is related to performance. label Aug 18, 2022
@tarhi-saad tarhi-saad self-assigned this May 18, 2023
@tarhi-saad
Copy link
Contributor

Upon some investigation, I realized that this bug had been resolved in this PR: #9251. The solution was to remove the dependency on block-editor from frontend blocks.

@gigitux, @Aljullu, could you please double-check? If it works for you, feel free to close this issue! 🙌

@gigitux
Copy link
Contributor Author

gigitux commented May 22, 2023

@tarhi-saad You're right! I'm not able to reproduce anymore! We can close this issue and #4543! I will proceed with it! @Aljullu feel free to open both issues if you find some issues!

@gigitux gigitux closed this as completed May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: i18n The issue/PR is related to internationalization. focus: performance The issue/PR is related to performance. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants