What are Translation folders?
In Magento 2, translation folders are directories that store translation files for different languages. These translation files contain the translated text strings used in the Magento storefront or admin panel. Using translation folders, you can provide localized versions of your store to cater to different regions and languages.
There are two main translation folders in Magento 2:
- app/code/<Vendor>/<Module>/i18n: This folder is used for module-specific translations. If you have custom modules or third-party extensions installed on your Magento store, you can place translation files in this folder to translate the text strings used within those modules.
The translation files in these folders have the
.csv file extension and follow a specific naming convention. The naming convention is as follows:
For example, if you want to provide French translations for your theme or module, you would create a file named
fr_FR.csv within the respective i18n folder.
Each translation file contains a list of comma-separated values (CSV) with two columns: the original text string and its corresponding translation. For example:
“Original Text”,”Translated Text”
“Add to Cart”,”Ajouter au panier”
Magento will automatically use the appropriate translation file based on the user’s locale settings. If a translation is available for the user’s language, Magento will display the translated text; otherwise, it will fall back to the default text.
To enable translations, ensure that the locale is set correctly in the Magento configuration and that the translation files are properly placed in the respective i18n folders. Magento’s translation system will handle the rest and provide the appropriate translations based on the user’s locale.