
Magento 2 uses translation dictionaries (CSV files) in modules and themes to localize UI text.
You can customize phrases by adding your own CSV in the module’s i18n folder. For each locale (like en_US), Magento automatically merges all module CSVs into one language dictionary.
Magento applies translations in a defined order:
- Module translations:
<module_dir>/i18n/ - Translation package:
app/i18n/ - Theme translations:
<parent_theme_dir>/i18n/(iterated through all ancestor themes)<current_theme_dir>/i18n/
- The database (translations located in this database take precedence and override translations stored in other locations.) Refer to the user guide for more information.
In practice this means your custom module’s i18n/en_US.csv entries load first for that module’s scope.
Creating Your Module Translation File
To add translations for your module, do the following:
- Create the
i18nfolder. In your module directory (for exampleapp/code/YourVendor/YourModule/), make a new subfolder namedi18n. - Create a locale CSV file. Inside
i18n, add a file nameden_US.csv(or another locale likede_DE.csv). This is the translation dictionary for your module’s phrases. - Add translations. In the CSV, list each string in two columns: the original (English) phrase and your translation. For example:
"Apply","Redeem" "Add to Cart","Add to Basket"
After adding or changing translations, flush caches and redeploy static content if necessary. Magento will pick up your CSV automatically when loading the storefront.
Example en_US.csv in a Custom Module
For instance, suppose you have a custom module YourVendor/YourModule. You would create the file: en_US.csv
app/code/YourVendor/YourModule/i18n/en_US.csv
with contents like:
"Apply","Redeem" "Submit","Confirm Submission"
Each line has the exact original phrase and its replacement. In this example, Magento will display “Redeem” instead of “Apply” when that text is used by your module.
Because the file is named en_US.csv, it overrides English text. To add other locales, simply copy this CSV and rename it (e.g. de_DE.csv), then translate the right-side phrases.
According to Adobe docs, translation dictionaries in modules let you customize strings without editing code.
The new translation system assembles all module CSVs into the language dictionary, so your entries become part of the overall translation.
Note that theme or language-pack translations loaded later could override module entries if the same phrase appears elsewhere.
That’s all
If any issue or doubt please feel free to mentioned in comment section.
I would be happy to help.
Happy Coding!!! 🙂

Be the first to comment.