The language translation is a key feature in odoo. It may help the end-user to use odoo in an efficient manner. So when we customize certain modules, we may need this kind of translation for its best utilization. Here, in this blog, we are discussing how to add translation to the custom modules. For that, we are using the language exporting feature that odoo provides. This simply makes it easy to implement language translation.
Make sure that our custom application or module is ready to install and there is only this translation part that is pending.
If we want to add translation to our module, we need a po file. The naming of the file should be language iso code and .po extension.
I have a custom module named Employee Shift, and here I am going to add a German / Deutsch translation for this module. For that,
1. Install the custom module
2. Activate the Developer mode
3. Go to Settings -> Translations -> Import/Export -> Export Translations
Here, select the language as a New Language. Set the file format as PO file and select the application. Here I have selected my custom module. Click on the button EXPORT.
> When we export , we get a file called custom_module.po ,which simply lists translatable strings and from which actual translations (PO files) can be created.
> The po file contains these two keywords
a) msgid :- which contains the actual text.
b) msgstr:- which contains the text you want to display for the translation.
> In the downloaded po file, add your translation terms.
> Go to Translations -> Languages -> Select the language(Here German/Deutsch)
> Select the languages ISO code and rename the file name to language_iso_code.po
> Create i18n folder under your module and add this language_iso_code.po file in it.
> Restart the service.
> We can load the translation by going to Settings -> Translations -> Load a translation.
a) Select the language that you want to load.Here I am loading the German/Deutsch language
b) Make sure that you have ticked the checkbox-Overwrite Existing Terms.if this is ticked, your customized translations will be overwritten and replaced by the official ones.
> Change a user language to German/Deutsch. Go to User -> Preferences -> Change the language.
> You can see your custom module’s labels, string, etc is translated to German/Deutsch language.
This is how you add translations to your custom modules.