In this article, you will learn how to perform Magento theme files translation. Usually, the translations are being stored in the .csv files on your server. However, if for some reason there’s no CSV translation file translated for your language – you will need to create the .csv file from scratch. To create the CSV translation file – please follow the steps below.
Make sure to disable the Magento cache before proceeding with .csv file translation.
Step 1. Create the required file for translation
First you need to set a locale in your Magento admin panel and create a translate.csv file in it. Please, check the directory:
This is an example of the file for German translation:
Step 2. Translate the phrases according to the requirements
While translating, make sure all the strings in your .csv file start and end with double quotes, and are separated with comma [,], not semi-colon [;] or any other mark.
"Add to Cart", "Translated Text"
You can change the default theme strings according to the requirements of your website.
"My Cart","My Basket" "My Account","Your Account"
All the lines are case-sensitive, you should copy the phrase exactly as it is in the “en_US” version.
In the source “en_US” version the text looks like this:
"%s Item(s)","%s Item(s)"
Whereas the translated text should look like this:
"%s Items","%s Product(s)"
If you need to set off a word or phrase by quotation marks, put two double quotation marks for such string.
You can also use HTML coding to alter your text. Check an example:
Step 3. Save the CSV file in UTF-8 encoding
Make sure your text editor saves .csv files in UTF-8 encoding, as it supports different alphabets. If you edit the file using Excel, convert it into UTF-8 encoding once you finish editing.
How to translate the same element differently for different pages
While performing translation in this file – any word or phrase will be translated for the entire theme. If you need to translate the same element in different ways for different pages, you can use this example:
"Mage_Catalog:Add to Cart","Add to Basket" "Mage_Checkout:Add to Cart","Add to my shopping cart"
To read more information about Magento translations, please click here.