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:
"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 →"
- Open
src/SearchAutocomplete/i18n/
directory to find the translation files; - Make a copy of original
en_EN.csv
file, for example,nl_NL.csv
file; - Open
nl_NL.csv
file for editing;
- If Fast Mode enabled at the Autocomplete settings
- If Fast Mode disabled
-
Change lines as below:
"Sorry, nothing has been found for ""%1.""
change%1
to%s
View all %1 results →
change%1
to%d
Examples:
"Sorry, nothing has been found for ""%s."", "Sorry niets gevonden voor ""%s.""
"View all %d results →", "Bekijk alle %d resultaten →"
-
Temporarily disable a Fast mode in the autocomplete settings;
-
Run static content deploy;
-
Enable Fast Mode and run Magento reindex.
-
Change lines as below:
"Sorry, nothing has been found for ""%1."", "Sorry niets gevonden voor ""%1.""
"View all %1 results →", "Bekijk alle %1 resultaten →"
-
Run static content deploy
Please do not add both kinds of translations in your locale file for a Fast mode enabled and disabled option. It will not work.