Localization in Akeneo:
Translation and localization are both main features of Akeneo or any PIM (Product Information management) system.
While adding features in Akeneo or creating a module for Akeneo. the user will need to add messages and their translations.
So, let’s use some messages and add their translations.
This could be done in 3 simple steps:
Step 1:
First, specify messages to translate.
In javascript
Suppose user want to add the translation in akeneo for some messages.
then the user can use already present oro/translator requireJs module in his/her module. for that user need to register module in requirejs.yml
# config/requirejs.yml config: paths: pimenrich/custom/mymodule: pimenrich/js/custom/mymodule
Then, use oro/translator module in js module
// in defination of module pimenrich/js/custom/mymodule "use strict"; define( [ 'oro/translator', ], function( __, ) { var msg = __('message to be translated message'); //now msg contains translated message } );
In HTML template
The user can also translate messages into HTML template using underscore.js.
For translation, underscore.js must be available in the template.
then, the user can translate messages like
<p> <%- _.__('message to be translated') %> </p>
Step 2: Adding Translations in files
Now, the user will finally need to add the translated messages in config files.
In any enabled bundle Go to Resources/translations/jsmessages.{locale}.yml (like jsmessages.fr.yml), and add the translation in the key-value pair like:
message to translated: message à traduire
Step 3: Clear Cache
Then, dump translation by running this command from the terminal:
php bin/console oro:translation:dump
After clearing the cache of Akeneo and browser, you can see these changes in the webpage of Akeneo.
Be the first to comment.