Magento 2 - Conflict in localisation csv file
-
15-04-2021 - |
سؤال
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
المحلول
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 inapp/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.