Back to Top

How to Add Translation for a Custom Module in Magento 2

Updated 16 September 2025

translation-module-cover

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:

  1. Module translations: <module_dir>/i18n/
  2. Translation package: app/i18n/
  3. Theme translations:
    1. <parent_theme_dir>/i18n/ (iterated through all ancestor themes)
    2. <current_theme_dir>/i18n/
  4. 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

Searching for an experienced
Magento 2 Company ?
Find out More

To add translations for your module, do the following:

  1. Create the i18n folder. In your module directory (for example app/code/YourVendor/YourModule/), make a new subfolder named i18n.
  2. Create a locale CSV file. Inside i18n, add a file named en_US.csv (or another locale like de_DE.csv). This is the translation dictionary for your module’s phrases.
  3. 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!!! 🙂

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home