11 July 2017
The Magento eCommerce platform enables you to localise your store for multiple regions and markets
If your store has multiple views in different languages and you have set the locale for each view to a different language, the result is a partially translated site.
The “loading” priority for translation files is
1. app/locale/{locale}*.csv
2. app/design/{package}/{theme}/locale/{locale}/translate.csv
3. inline transaction from database (core_translate).
The priority is reversed when translations are applied to the frontend.
So, follow this checklist if your translation from translate.csv is not working
a. Is the translation cache turned off or refreshed?
b. Is the translate.csv really in the theme fallback for the current store?
c. Is there a conflicting record for the translation in the core_translate table?
d. If all the previous points are not the cause, there must be a conflicting translation from a different module.
In any instance where two modules have the same translate string, priority is given to the current module first (if the translation is called from the current module files), and then it also depends on which module loads first.
Translations are loaded in the ‘core/translate’ model in the init() function
The code written there is
foreach ( $this->getModulesConfig() as $moduleName => $info ) { $info = $info->asArray(); $this->_loadModuleTranslation($modulename , $info['files'], $forceReload ); } $this->_loadThemeTranslation($forceReload); $this->_loadDbTranslation($forceReload);
Let us look at an example:
If you have two modules Mage_Foo and Mage_Bar, both have a translate string 'Hello'.
This is how Magento stores it internally:
Mage_Foo::Hello => Foo1 Mage_Bar:Hello =>Bar1
so if we call
Mage::helper('Foo')->_(“Hello”) // this will print Foo1 Mage::helper('Bar')->_(“Hello”) // this will print Bar1
A problem can occur when we call the translated string from a third module, which itself doesn’t contain a translation value, for example:
Mage::helper(“Test”)->_(“Hello”)
The string which will be printed depends on which module loads first, Foo or Bar.
If you find this problem, simply add the translation a second time to your translate.csv with the module scope of the module doing the translation.
Use a translation like this for each case:
__('text here')?>
In the example, if you always wanted AAA to be translated as DDD via the theme translation, you could do this in your translate.csv:
"AAA","DDD" "Mage_Catalog::AAA","DDD" "Some_Module::AAA","DDD"
In practice, we only add the module scope to the translation if there is a conflict, that is, if a translation isn't working.
For more information, feel free to contact us for Magento Support