Pages

Monday, 23 June 2014

Magento Developper Guide (Lesson 15) – Translate your Magento plugin, the Internationalization

This tutorial is the 15th of many tutorials . If you have not read the first articles yet, I strongly advise you to do so.

As you know the websites are often translated into several languages​​, this plugin was not translated from one language to another, it is now time to get started.

On Magento, you will find translations in folder/app/locale/ , is in fact the code for the language. For example the French translations will be found in /app/locale/fr_US and the German’s will be in de_DE.

The files format is CSV and structure is as follows:
[txt]
« String to translate », « String to translate »
[txt]
Files must be declared in your config.xml plugin:

<translate>
  <modules>
    <Easylife_Test>
             <files>
          <default>Easylife_Test.csv</default>
       </files>
    </Easylife_Test>
  </modules>
</translate>
 
Now when you want to translate your string, use:
 
<?php echo $this->__('String to translate'); ?>
//result: String to translate
 
Magento will search for the corresponding translation to your chain in your csv file. if you are in US, it will search the correspondence in the file/app/locale/fr_US/Easylife_Test.csv, then he will find the string « String to translate » and return « String to translate. »

I hope it will helps.


Find the summery of this tutorial

No comments:

Post a Comment