Translating Magento – Template

One way of translating in Magento is by using the translations available in a theme. However this needs to be activated in the Administration area.

Log in to the Magento Admin -> Configuration -> Design -> Design -> Themes -> Translations. In this text field submit the name of the theme that is to be used for translations. Note that this will need to have the corresponding translate.csv file in the locale directly of that theme.

The translate.csv file will need to be located in the theme specified (Administrator configuration area):
/app/design/frontend/default/{theme}/locale/{language_sortcode}/translate.csv or /app/design/adminhtml/default/{theme}/locale/{language_sortcode}/translate.csv

If this file does not exist, simply create it.

If it does not contain the translation that is required, enter the the translation string enclosed in double quotes followed by the translation string in double quotes, separated by a comma. For example:
“{string for translation}”, “{translated string}”

This will first pick up any local locale files that are being used for translation, for example: /app/locale/{language_sortcode}/{Namespace}_{Module}.csv. To override this it is necessary to implement a variation in format of the “{string for translation}” string in the .csv file to the following: “{{Namespace}_{Module}::string for translation}”, “{translated string}”. This may be better understood with an example. Consider that in the .phtml file it is desirable to introduce a string for a value defined as ‘fluff’. So in the .phtml file we place the following in the file:

<?php echo ($this->__('fluff')); ?>

Without any intervention the output would be seen as the string ‘fluff’, but this can be used for translation by inserting the string into either the frontend or administrator .csv file, depending on the file location that the fluff string has been entered. If it is assumed that the fluff string has been entered into the administrator location then it is possible to edit, or create, the file /app/design/frontend/default/{theme}/locale/{language_sortcode}/translate.csv. Inside this we put in the code:
“fluff”,”FLUFF”.
Now when viewing the page that had the echo ($this->__(‘fluff’)); code entered the uppercase version of the string should be seen. However, if this string was part of a code defined in Mage_Customer, then in the translate.csv file the entry would look more like: “Mage_Customer::fluff”,”FLUFF”

In the php/phtml file that you want translation to occur, the required translatable string is created with the syntax: $this->__(‘{string for translation}’)

One other area of note is that a language short code will be required, for British English this will be en_GB and American English is en_US.

Some possible others are (not verified):
English, US (en_US)
German, Germany (de_DE)
Chinese, PRC (zh_CN)
Chinese, Taiwan (zh_TW)
Czech, Czech Republic (cs_CZ)
Dutch, Belgium (nl_BE)
Dutch, Netherlands (nl_NL)
English, Australia (en_AU)
English, Britain (en_GB)
English, Canada (en_CA)
English, New Zealand (en_NZ)
English, Singapore(en_SG)
French, Belgium (fr_BE)
French, Canada (fr_CA)
French, France (fr_FR)
French, Switzerland (fr_CH)
German, Austria (de_AT)
German, Liechtenstein (de_LI)
German, Switzerland (de_CH)
Italian, Italy (it_IT)
Italian, Switzerland (it_CH)
Japanese (ja_JP)
Korean (ko_KR)
Polish (pl_PL)
Russian (ru_RU)
Spanish (es_ES)
Arabic, Egypt (ar_EG)
Arabic, Israel (ar_IL)
Bulgarian, Bulgaria (bg_BG) 2.3
Catalan, Spain (ca_ES) 2.3
Croatian, Croatia (hr_HR) 2.3
Danish, Denmark(da_DK) 2.3
English, India (en_IN) 2.3
English, Ireland (en_IE) 2.3
English, Zimbabwe (en_ZA) 2.3
Finnish, Finland (fi_FI) 2.3
Greek, Greece (el_GR) 2.3
Hebrew, Israel (iw_IL)* 2.3
Hindi, India (hi_IN) 2.3
Hungarian, Hungary (hu_HU) 2.3
Indonesian, Indonesia (in_ID)* 2.3
Latvian, Latvia (lv_LV) 2.3
Lithuanian, Lithuania (lt_LT) 2.3
Norwegian-Bokmol, Norway(nb_NO) 2.3
Portuguese, Brazil (pt_BR) 2.3
Portuguese, Portugal (pt_PT) 2.3
Romanian, Romania (ro_RO) 2.3
Serbian (sr_RS) 2.3
Slovak, Slovakia (sk_SK) 2.3
Slovenian, Slovenia (sl_SI) 2.3
Spanish, US (es_US) 2.3
Swedish, Sweden (sv_SE) 2.3
Tagalog, Philippines (tl_PH) 2.3
Thai, Thailand (th_TH) 2.3
Turkish, Turkey (tr_TR) 2.3
Ukrainian, Ukraine (uk_UA) 2.3
Vietnamese, Vietnam (vi_VN) 2.3

Resources:

Leave a Reply

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