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_FR and the German’s will be in de_DE.

The files format is CSV and structure is as follows:

[txt]
« String to translate », « la chaine traduite »
[txt]

Files must be declared in your config.xml plugin:

<translate>
  <modules>
    <Pfay_Test>
             <files>
          <default>Pfay_Test.csv</default>
       </files>
    </Pfay_Test>
  </modules>
</translate>

Now when you want to translate your string, use:

<?php echo $this->__('String to translate'); ?>
//result: la chaine traduite

Magento will search for the corresponding translation to your chain in your csv file. if you are in French, it will search the correspondence in the file/app/locale/fr_FR/Pfay_Test.csv, then he will find the string « String to translate » and return « la chaine traduite. »

I hope it will helps.

Go to the summary of this tutorial

Posted in magento.


7 Comments

    • Hi Sandeep ;) Not for the moment, but soon you will have much better. In more or less one month i will provide you a huge help for all magento developpers. I’ll in the next days insert a subscription form…you will be able suscribe and received an invitation ;)

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>