Magento Translations Module

One of best things in magento is you can easily add new language versions to the site. It's all done using CSV files - 1 file for 1 module per language. For most popular languages translations are available as free Magento modules on magento connect.

What if we want to change the translations and don't lose changes after updating magento and translations? Or if we want to have translation common independently of module? Or just list all the texts that were added by us and are not original magento texts? We can create our own very simple translations module.

You need to edit only 2 files:

  • etc/config.xml
    <?xml version="1.0"?>
    <config>
            <modules>
                    <Baobaz_Translations>
                            <version>0.1.0</version>
                    </Baobaz_Translations>
            </modules>
           
            <global>
                    <helpers>
                            <translations>
                                    <class>Baobaz_Translations_Helper</class>
                            </translations>
                    </helpers>
            </global>
           
            <frontend>
                    <translate>
                            <modules>
                                    <Baobaz_Translations>
                                            <files>
                                                    <default>Baobaz_Translations.csv</default>
                                            </files>
                                    </Baobaz_Translations>
                            </modules>
                    </translate>
            </frontend>

    </config>
  • and helper/data.php:
    class Baobaz_Translations_Helper_Data extends Mage_Core_Helper_Abstract
    {

    }

and that's it... Module must be turned on (in etc/modules) and it will work fine.

in app/locale/fr_fr/ we create file Baobaz_Translations.csv and in it we put all the new translations we need.

Then, anywhere in magento - doesn't matter if it's template, block or controller - we can use:

echo Mage::helper('translations')->__('text to translate');

Yes. It is that simple.

12 comments on "Magento Translations Module"

evuska's picture
evuska (visitor) - Fri, 13/11/2009 - 14:28:

Great, great!

Thank you so much!!

Pedro's picture
Pedro (visitor) - Tue, 18/05/2010 - 19:13:

Thanks for this will help to translate custom themes to portuguese. Just one question, what's the path for helper/data.php? Can it be in the theme's files?

Thanks

magento developer's picture
magento developer (visitor) - Mon, 20/12/2010 - 12:25:

2 Pedro:

all localization files are in translations, u don't need to translate data.php. Use inline translate tool to see where the file should be translated.

Magento Development's picture
Magento Development (visitor) - Fri, 04/02/2011 - 12:29:

its nice blog with unique content and thanks for sharing.

Paul Web's picture
Paul Web (visitor) - Wed, 30/03/2011 - 04:53:

Thanks for putting this out, it is simple (or at least more simple than I had imagined it would be.) You've saved me hours of head-scratching, cheers!

Regards,
Paul
Managed Dedicated Server

Anonymous's picture
Anonymous (visitor) - Wed, 30/03/2011 - 13:15:

FirstTryCertify.com is dedicated to providing high quality practice exams. If you are looking for top quality MICROSOFT exam practice exams, FirstTryCertify.com is what you need. With live chat services and quality CT0-101 dumps, or LX0-101 dumps, FirstTryCertify will help you in passing your MICROSOFT exam. LX0-102 dumps , N10-004 dumps,SK0-003 dumps ,SY0-201 dumps, any exam you need FirstTryCertify has.
Top of the line I.T Certification exam, study guide, test questions, exam questions or even MICROSOFT dumps. FirstTryCertify has the best EX0-101 dumps on the market. MICROSOFT Certification training is time consuming and FirstTryCertify.com can help you with studies. If you are studying and need VCP-410 dumps, 70-270 dumps , 70-284 dumps or 70-291 dumps or even 70-290 dumps, FirstTryCertify can help with your studies. Pass On Your First Try or your Money Back.

Anonymous's picture
Anonymous (visitor) - Thu, 20/10/2011 - 12:18:
Microsoft Office 2010's picture
Microsoft Office 2010 (visitor) - Fri, 02/12/2011 - 06:27:

I will keep your new article. I really enjoyed reading this post, thanks for sharing.

gianmarco lorenzi's picture
gianmarco lorenzi (visitor) - Wed, 07/12/2011 - 10:34:

gianmarco lorenzi shop sales the full range of shose.Whether gianmarco lorenzi boots or gianmarco lorenzi pumps,you can see here.Even if you want to buy gianmarco lorenzi sandals in winter is also possible.

soldes lancel's picture
soldes lancel (visitor) - Wed, 11/01/2012 - 10:57:

 La première mondiale et 41 en France métropolitaine la première montre Lancel et des boutiques de sac lanceles hiver 2012" href="http://www.ventepriveelancel.com/solde-lancel">soldes hiver 2012 bijoux à Shanghai en 2007, l'ouverture du premier étage de Hang Lung Plaza.Les exposants qui était maintenant garder les États-Unis et le monde a joué seulement une broche. Les soldes sac lancel plumes sont couramment utilisés dans les années 30 accessoires pour femmes, Lancel d'inspiration dans la conception d'une plume de plumes et d'ornements sac; comme la méditation sous les sac lancel premier flirt étoiles, elle germination des «femmes en arrière-plan lumineux étoiles élégance incomparable» de lancel brigitte bardot l'imagination, puis concevoir une forme d'une étoile de la faire?Lancel Sac Lancel maintenant le patrimoine dans la conception de Lancel est toujours président de l'essence du design. "Nous allons trouver les moyens les plus appropriés de pierres précieuses et des lancel bb services de traitement de mosaïque dans notre conception, les caractéristiques des deux dans de nombreux détails inclus dans," a dit M.

http://www.ventepriveelancel.com/

Anonyme's picture
Anonyme (visitor) - Sun, 15/01/2012 - 22:55:

происхождение фамилии есин значение фамилии григорьев значение фамилии арсланова
значение фамилии значение фамилии казаков история и значение фамилии

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options