Magento 2 Translation extension is an alternative to Magento 2 Translate Inline Tool. It allows anyone to add translation of buttons, labels and short-form content (up to 250 characters) directly from the admin.
You don't have to switch to developer mode to add translations. So any admin user can add translations without any technical skills.
Translation extension by Magefan doesn't require any configurations. So, in this article, you will learn how to add new translations, export and import them. Follow the instructions below, or watch the video later in this article.
Add New Translations
For this example let's translate the "Add to Cart" button on the product page.
Once you install the Translation Extension, new section will be added to your Magento 2 admin panel. So...
To add a new translation in Magento 2:
1. Go to System > Tools > Translation by Magefan.
2. Once on the translations page, press Add Translation button.
3. Add Original Text you want to translate for some of your store views and add the Translated Text.
4. Choose the Store View to add this translation to.
Note: you select store views only in case you have a multi-website with 2 store views in the same language and want to add different translations for each of them.
e.g. you have German (Germany) store view on Website #1 and German (Germany) store view on Website #2 and want to have different translations for each of these store views.
5. Choose the language you add the translation for in the Locale dropdown.
Note: make sure you set different locales for each of your store views when creating store views. If you don't set the locale translations won't be applied.
Don't forget to Save the Translation.
6. Flush Magento cache and go to the storefront to check the translation.
Want to see it in action? Watch this short video:
If you want to export your translations, you can export them via CSV or Excel XML files on the translations page (System > Translations by Magefan).
In case you already have some translations you've added with the Magento 2 Translate Inline Tool, you can import them.
To import translations go to System > Import, select Magefan Translation as the Entity Type and run the import.
So, that's it. It is much easier to add the translations in Magento 2 with Magento 2 Translation extension.
Our extension works on the Magento translation functions and provides 100% translation if the text code provided is correct.
So, if you've completed all of the steps correctly, but the text still won't translate, check if the text you try to translate is wrapped in the translation function. It might be that developers didn't wrap the text in the translation function in their module or theme.
Translation conditions weren't created and the text wouldn't translate even you applied the language packs to it.
Regarding the file type, you have to use different translation functions:
- if this is *.php file or *.phtml file use __('yourtext')
- if this is the *.js file use mage.translate
- if this is for cms block or cms page trans function
- if this is *.html file you can use <span data-bind="i18n: 'yourtext'"> or </span> <span translate="'yourtext'"></span>
php bin/magento setup:static-content:deploy
The other case might be that the text you're trying to translate is generated with variables e.g. "%1 reviews", "Please enter a valid date between %1 and %2 at %3.".
So, you have to add translation with the variables too. Besides, you can use Translate Inline Tool to work with the variables easier.
Finally, please note that Magento 2 Translation extension is not used for long-form content translations. You have to add long translations manually and we got just the guide for you.