Magento can manage multiple stores in a single installation. There are three layers in this hierarchy – websites, stores and store views.

The top level is Website. It’s made up of one or multiple stores. They in turn are made up of one or multiple store views. Stores have the same customers, orders and shopping carts. They are set of store views and the main idea of stores is to group store views in a website.

Most of Magento installations have only one website with one store and only one store view. As store Views are the actual store instances, they are typically used for internationalization purposes, i.e. translation of your store into different languages. Therefore, if you need to display your store in multiple languages, for example English, French and German, you should create the store once and then create three different store views for this particular store.

New store view can be created via Magento Admin panel. Log into it, select System -> Manage Stores and click Create store view.

Next, you need to fill the form and select Store, enter your store name, its code, status, sort order and then Save Store View.

After that you need to go to System -> Configuration, choose the needed store view and find Locale options section under General tab. Next, from Locale drop-down, select the right one (the first comes language, the second – country, for example, for Canadian English it would be English (Canada)).

Next, you need to download translation package/files. They can be downloaded from the official Magento site, either from Translations directory added by contributors or from Magento connect added by Magento core team.

After refreshing caches we’re all set; in default Magento, the store view can be accessed via http://yoursite.com/index.php?___store=store_code. There is also a setting to add store_code into URL like this http://site.com/index.php/store_code. It can be set up in System -> Config -> Web -> Url Options -> Add Store Code to Urls.

The use of Magento translate classes and translate files.

Everywhere in Magento templates (.phtml files) you can see something similar to this one $this->__(‘some string’). Actually it’s Mage::helper(‘core’)->__()

As we can see, Magento supports and loads three different types of translations data – Module translation, Theme translation and DbTranslation. Let’s look at one of these methods more thoroughly: _loadModuleTranslation (just need to be mentioned that all three methods call _addData method inside their code).

And finally, in this method we can see how Magento adds translation data. Inside of this method, Magento checks whether developer mode was set to true (if (Mage::getIsDeveloperMode())) and, if so, it’s not allowing to use translation, not related to module (i.e. unset data array).

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

/**

* Adding translation data

*

* @param array $data

* @param string $scope

* @return Mage_Core_Model_Translate

*/

protectedfunction_addData($data,$scope,$forceReload=false)

{

foreach($dataas$key=>$value){

if($key===$value){

continue;

}

$key=$this->_prepareDataString($key);

$value=$this->_prepareDataString($value);

if($scope&&isset($this->_dataScope[$key])&&!$forceReload){

/**

* Checking previous value

*/

$scopeKey=$this->_dataScope[$key].self::SCOPE_SEPARATOR.$key;

if(!isset($this->_data[$scopeKey])){

if(isset($this->_data[$key])){

$this->_data[$scopeKey]=$this->_data[$key];

/**

* Not allow use translation not related to module

*/

if(Mage::getIsDeveloperMode()){

unset($this->_data[$key]);

}

}

}

$scopeKey=$scope.self::SCOPE_SEPARATOR.$key;

$this->_data[$scopeKey]=$value;

}

else{

$this->_data[$key]=$value;

$this->_dataScope[$key]=$scope;

}

}

return$this;

}

How many options exist to add a custom translation for any given string?

As mentioned above, there are three options in Magento to add a custom translation to a text string: module translation, theme translation and inline translation.

1. Module translation

Module translations are stored in app/locale/languagecode_COUNTRYCODE/ folder in form of csv files, named as Namespace_Modulename.csv All string in extensions that are inside __() method can be translated this way

2. Theme translation

Strings can be translated inside your theme, for that you just need to set locale via Magento admin area, then create translate.csv in app/design/frontend/<package>/<theme>/locale/ languagecode_COUNTRYCODE and put your translated strings inside this CSV

“My Cart”,”My Basket”

“My Account”,”Account”

There are a lot of tips&tricks that can be described on this subject (module and theme translations), so I feel like they deserve an individual article. Stay tuned!

3. Inline translation

To enable inline translation you need to log into Admin panel and go to System -> Configuration -> Developer.

You need to select Store view from scope select and enable inline translation for this desired store view there.

All translation made by this method will be stored in core_translate table inside your database. In order to understand better how this method works, check this video out.

Sergei Guk is Certified Magento Developer in BelVG. He has a strong background in Magento, OXID and Prestashop as well as in PHP, MySQL, MVC, HTML, Ajax, CSS, JavaScript, jQuery, AJAX, SOAP, OOP, DBD, Zend Framework, Code Igniter and Cake PHP. It allows him to come with brilliant module ideas for our company.

His character is forged by Muay Thai (a combat sport from Thailand) and mind – by piano classes and continual reading (Orwell, Huxley, Vonnegut). Fond of photography and crazy about his funny golden retriever named Sly.

Hi! Thank you very much for your posts, its had really helped me a lot in my preparation for the exam. Their contributions are very very welcome. On this issue of the translation, I got lost at one point. Say that Magento loads the translations in order of: first the Module Translation , then Theme Translation, and finally the Inline Translation. However, the priority in deciding what show, is reversed and the first option Inline Translation?

I have a question about internationalization: Is it possible to use ‘Module translation’ in the email templates? For me it would be useful, because the html part is always the same for all the languages, and I would like to have all the email text elements together in a csv file…

Hey Sergei,
If you need an online tool to translate .csv files in a team, I warmly recommend you check out the localization management platform https://poeditor.com
I think it’s one of the simplest solutions to automate localization projects.