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.
Step 1. Create a CSV file & copy phrases for translation
your_lanuage_code.csv file 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
Step 2. Translate phrases in each string
.csv file 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"
Step 3. Remove the js-translation.json file
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:
Step 4. Deploy the CSV file with translation
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
Step 5. Flush Magento cache
Flush Magento Cache using the following command:
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.