Question

I understand the general structure of i18n csv files that is like

<key_hook>,<translation_of_that_key>

but according to the documentation there is the possibility to add a module restriction:

<key_hook>,<translation_of_that_key>, module, <module_vendor>

In my case in de_DE.csv (in my custom theme i18n directory) I've used:

"Summary", "Zusammenfassung", module, Magento_Review
"Summary", "Kassenübersicht", module, Magento_Checkout

The problem is now that if the customer likes to write a review on the single product page, there is still "Kassenübersicht" instead of "Zusammenfassung". Why is that? Does this restriction really work? Do I (really) have to use different original Translation Hooks?

Magento Verion 2.3.5

Was it helpful?

Solution

Magento's translations are a pain and the documentation for them is even worse.

Theme translations are global and will affect the string regardless of the module, to translate on a per module basis you need to use a translation package. I'm not sure if this is intentional behaviour or if it's a bug that module based translations don't work in the theme.

The main differences between theme translation and translation packages are:

  • They support module based translations
  • Theme translations are placed in {theme}/i18n/ whilst translation package are placed in app/i18n/
  • Translation packages require registration.php and language.xml files

You can find instructions for how to create a translation package here. Note that it's optional to gather all the available strings.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top