In this article, you will learn how to translate your Magento 2 extensions.
Generally, Magento uses a translation dictionary so that you can localize your store. This dictionary is a .csv file with two columns: the original text in the source (en_US) locale and the translation of that text in a target locale. Therefore, you need to perform Magento 2 CSV files translation by adding and applying the translation phrases.
1. Adding Translation Phrases
- Create the
your_lanuage_code.csvfile in the
- Copy the phrases you need to translate from the following file:
If the file is missing, you need to add a set of phrases for translation manually into the
- Open this
.csvfile using any text editor (e.g. Notepad++) and translate the phrase in each string. All the phrases in your .csv file should be written in double quotes and should be separated by commas [,]
"Add to Cart", "In den Warenkorb"
2. Applying the Translation
Now you have to apply the translation you have entered in the
.csv file. Please, proceed with the following steps:
In Developer mode, you can disable Magento Cache to display changes instantly (does not apply to JS translation).
- In the terminal, switch to your Magento 2 root directory using the following command:
- Remove the following file:
- Next, run the following command to deploy the translated file (please skip this step if Magento is in developer mode):
php bin/magento setup:static-content:deploy --theme <vendor>/<theme_name> <locale_code>
php bin/magento setup:static-content:deploy --theme Magento/luma de_DE
- Flush Magento Cache:
php bin/magento cache:flush
Please make sure to refresh the page after you have applied your translation. If necessary, please check Magento DevDocs for more information about Magento 2 translation.