In my last post about translations I was explaining how to translate words in Magento with inline translation tool as an option, but there are more techniques for translating besides that.
In this post I will try to cover translations for custom modules so they all refer to a single csv file.
Ok first thing is to actually prepare words for translating. Translations will not work if we don’t use proper string for them. So string will look like this:
< ?php echo $this->__('desired word') ?>
Ok now we need to go to the app/code/ and create a directory for all custom modules, so we will make a directory named local. Inside we need to create another directory called Translations for translation module.
Now we should have this – app/code/local/Translations. Inside Translations directory we should make directory named /etc and create config.xml file with this content:
< ?xml version="1.0" encoding="utf-8"?> <config> <modules> <translations> <version>1.0.0</version> </translations> </modules> <frontend> <translate> <modules> <translations> <files> <default>Translations.csv</default> </files> </translations> </modules> </translate> </frontend> <adminhtml> <translate> <modules> <translations> <files> <default>Translations.csv</default> </files> </translations> </modules> </translate> </adminhtml> </config>
So what we created is a call for default translation file for all custom modules. After creating a call we need to create Translation.csv file and copy it to a app/locale/en_US/ and in all other language packs enabled. So if we have
french language copy the file in app/locale/fr_FR.
Next stop is to enable Translation module in app/etc/name_of_the_module.xml (Translations.xml) and we should paste this code:
< ?xml version="1.0"?> <config> <modules> <translations> <active>true</active> <codepool>local</codepool> </translations> </modules> </config>
After that everything should be working fine, just open the .csv file and start translating.
Hope this will help someone.