How to add your own translations to Extensions?

How to add your own translations to Extensions?

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"?>
 
 
1.0.0
 
 
 
Translations.csv
 
 
 
 
 
 
Translations.csv

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"?>
 
 
true
local

After that everything should be working fine, just open the .csv file and start translating.

Hope this will help someone.

Cheers!

You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 36

How To Connect Google Analytics 4 To Magento 2

3 best open-source eCommerce platforms in 2021 Zrinka Antolovic
Zrinka Antolovic, | 8

3 best open-source eCommerce platforms in 2021

Magento SEO: Check your extensions! Toni Anicic
Toni Anicic, | 10

Magento SEO: Check your extensions!

9 comments

  1. hi i m looking for such extension in magneto that help to translate or edit specific word in to other languages ……… is any one help me how i do that is any extension present or i have to make code for that and how i proceed it ?

  2. Hi Filip,

    Thanks for your article and for pointing me in the right direction to add translation to a module that didn’t have one 🙂

    This module of yours adds translation for all custom modules but is there a way of adding my own Company_Translations.csv at a global level to substitute the 2 translate.csv under adminhtml and frontend respectively? app > etc > config.xml?

    It’s a constant work of partly adding to the translation of Mage and for the extensions I use as a base for every installation. New words are added, I decide on better phrasing things in Swedish etc.

    Most grateful for your help 🙂

    All the best

    Peter

  3. Hi,

    Is there any way to change the path to translate.csv?
    for example i need to put translate.csv file inside media folder and read the translations from media/en_US/translate.csv

    Is it possible? If so how?

  4. I followed your tutorial and found a bug. The tag has to be otherwise the translation won’t be loaded correctly and therefore won’t load.

  5. I can’t get this to work in Magento 1.6.1.0. In the admin area I can see the module is enabled. But I can’t get the translations to work and I don’t know how I can check where it goes wrong. Is this maybe not working in this version of Magento?

  6. @fishpig

    Yes you are right, that is a custom module that adds translations for all custom modules. So if you plan to re-use modules, yes than it’s not so good solution. In that case you can create .csv for each module. I will cover that in next post. You are right about codePool, and i missed some capital letters, my error i will correct that. Thanks for corrections.

  7. Nice article but I don’t understand whether you’re just showing how to add translations to a custom module or a custom module that you add translations to for ALL custom modules? If it is the latter, doesn’t this break the modularity of modules? If you want to re-use a module on another site you would have to copy over the extra translations module.

    Also, I think codepool should be codePool.

    Nice article though, I read your site a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.