3 Different Methods of Translation in Magento

Translation methods in Magento

Our Magento development team regularly gets a great amount of questions regarding translations in Magento. And it is easy to explaine. Magento is a very popular in a great amount of countries such as the UK, Germany, the USA, Austarlia and other. So, today, we have decided to tell you about 3 basic methods of managing translations, their priorities and peculiarities. We are going to present you the advantages and disadvantages of each solution. Also, we want to show which solution can meet your requirements when you change or add a new translation to your ecommerce website. So, let’s start.

What are 3 different methods of adding or changing translations in Magento?

Inline Translation 

The first method is the Inline Translation. If you add new translations by using this method, all of them will be placed in the database (core_translate table). You can enable the Inline Translation for frontend or backend separately. To do it,  you should open the admin panel of your store and follow the next steps: System -> Configuration -> Developer -> Translate Inline. Also, you can use the Inline Translation method to add a new translation to the Default Config (all stores) or to the specific store view. You should know that the overridden string (original translation) has the next format – Module_Name::Original_Translation. It is explained by the fact that you add the changes to a certain module. You have to know that the same string can appear in another module too.

Below, you can see an example of changing the translation for the Add to Cart button on the product page. The next popup can help you add a new string:

Magento translation popup

These changes will help you to see the next data in the “core_translate” table.

core translate table

Theme translation

The second method is the Theme Translation. It allows you to add a translation only to a specific theme. All changes will be placed in the CSV file with the next path:

app/design/{area}/{package}/{theme}/locale/{language_code}{country_code}/translate.csv

For instance, for the “modern” theme in the default package as well as for the English (US) locale we have the next path:

app/design/frontend/default/modern/locale/en_US/translate.csv

Please, remember that some of the strings may be translated several times in different modules. Therefore, we recommend to translate the Add to Cart button using the Module_Name::string (the same syntax as we used for the Inline Translation).

For instance, if we are going to change the QTY string on the cart page for the default theme, RWD package and English (US) locale, we need to enter the next line:

"Mage_Checkout::Qty", "Mage_Checkout::Item Qty"

in the file with app/design/frontend/rwd/default/locale/en_US/translate.csv path.

Module translations

This kind of translation is used for Default Config (all stores). It is stored within:

app/locale/{language_code}_{country_code}/{namespace}_{module}.csv

For instance, below there is the path to the module translation file for the Mage Catalog module:

app/locale/en_US/Mage_Catalog.csv

Sometimes, it is necessary to change the translations of the core or a third party module. As practice shows, to edit files is a wrong way here. Consequently, we have to add changes in a different way. Lets check which of them is better to chose.

Advantages and Disadvantages of Each Method

Inline Translation 

Plus: This method is easy and non-technical. It is not obligatory to know a lot about translations in Magento to be able to make such changes. It can be used as a default value (for all stores) or for a certain webstore view.

Minus: When you need to add a lot of changes, you have to be ready to spend considerably more time. Also, you may face some difficulties when you will be applying them to other Magento stores.

Theme translation

Pluses and minuses depend a lot on your needs: It can be applied just to the theme where changes are added. The best solution is to make changes only in a current theme. And the worst course of events is when you have several themes and you need to add the same changes to all of them.

Module translation

Plus: Adding a translation file to your own/core/ third party module is considered as a good method.

Minus: However, it is much more difficult than the Inline Translation.

When there is a need to edit the translation in a certain module – the best way is adding an additional translation file to the module in which you are going to change the translation. After that, you should declare it in your module configuration file as we show below:

<area>

  <translate>

    <modules>

      <module_name>

        <files>

          <node_name>New_file_name.csv</node_name>

        </files>

      </module_name>

    </modules>

  </translate>

</area>

Also, you can try to change the “Add to Cart” in the Mage Catalog module. It is possible to do in our module’s (SaM_Catalog) configuration file (app/code/local/SaM/Catalog/etc/config.xml):

<config>

  ...

  <frontend>

    <translate>

      <modules>

        <Mage_Catalog>

          <files>

            <additional_file>SaM_Catalog.csv</additional_file>

          </files>

        </Mage_Catalog>

      </modules>

    </translate>

  </frontend>

</config>

In this case, another translation file is added to the module. As the translation files will be merged, it is important to add dependencies to the initialization file for your module (if it is needed). 

So, at this stage we can add the changes to the SaM Catalog translate file (app/locale/en_US/SaM_Catalog.csv):

"Add to Cart", "Add to Basket"

After the cache is cleared, we can see the results.

We hope that our description of all translation methods will help you with choosing one of them for your store. If you have some questions regarding this topic, our Magento development team will be happy to answer them! Read more about Magento here:

Comments (4):
Posted on Wednesday, September 14, 2016 by :
Your post captures the issue petfecrly!
Posted on Wednesday, September 14, 2016 by :
I really wish there were more arlcites like this on the web.
Posted on Wednesday, October 05, 2016 by :
To translate CSV files, you can use the localization management platform.This collaborative online solution can make your work more efficient, by means of automation features like GitHub/Bitbucket/GitLab integration, API, Translation Memory, and other such tools.I highly recommend it for increasing localization project productivity and simplifying the translation process.
Posted on Thursday, July 20, 2017 by :
Thanks for sharing. Your various ways for translating in Magento are very helpful to me.
Leave a comment:
*Your comment will be published after approval by site administrator.