Skip to main content

How to translate service messages

Our extension supports multilanguage stores. To translate it, we have used the same logic as default Magento.

1. Find i18n folders​

All our translation files are in the i18n folder of each sub-module.

i18n files should be located at:

  • If installed via composer: vendor/mirasvit/module-name/src/ModuleName/i18n
  • If installed manually: app/code/Mirasvit/ModuleName/i18n

2. Create a separate .csv file of your language for our extension​

The names of all languages can be found with this command:

php -f bin/magento info:language:list

3. Override the strings in your dictionary file​

First column is original line, second column your translated line:

example

"Original line" , "Translated line"

To avoid rewriting the file with the updating of the module, replace the translation file to your theme directory at app/design/frontend/THEME_VENDOR/theme_name/i18n/lg_LG.csv. Where lg_LG.csv is a translation file in another locale.


4. Apply translations​

To apply changes run static content deploy :

rm -rf pub/static/*
rm -rf var/view_preprocessed/*
php -f bin/magento setup:static-content:deploy
php -f bin/magento cache:flush

Examples​

Use the examples below to translate service messages in Autocomplete:

Translate "Sorry, nothing has been found for" and "View all results →"
  1. Open src/SearchAutocomplete/i18n/ directory to find the translation files;

  2. Open the translation file for your language if it already exists, or create a new one (e.g. nl_NL.csv) by copying en_US.csv;

  3. Add or update the lines as below:

    • "Sorry, nothing has been found for ""%1.""" → "Sorry niets gevonden voor ""%1."""
    • "View all %1 results →" → "Bekijk alle %1 resultaten →"
  4. Run static content deploy.

note

The same %1 placeholder is used regardless of whether Fast Mode is enabled or disabled.