how-to-add-translation-custom-module-odoo-13.png
Blogger_637003162157024481.png
By: Vinaya Suresh

How to Add Translation to Custom Module in Odoo 13

Technical Odoo 13

It is important to consider translations when we perform customizations in odoo. In this blog let us see how to add the translation for custom module and also the implicit and explicit exports in odoo13. In the module structure you can see a folder i18n which is used to add translation to your modules.


how-to-add-translation-custom-module-odoo-13


The i18n module consists of .po files. These .po files can be obtained by exporting the custom module. Let’s see how to perform this:


Activate Developer Mode Go to Settings -> Translation -> Export Translation.


Choose the custom module name of which you want to add translation.


how-to-add-translation-custom-module-odoo-13


Now Go to Settings -> Translation -> Export Translation


1. Select the required custom module. 

2. Export your custom module select the file format as po format. 

3. Choose the required language


Move the po file to the i18n folder of your custom module.


Place the translation as follows in .po file


    msgid ”custom text to be translated”
    msgstr “translation for the string/text”


You can also see the translated terms and status using Translated Terms


how-to-add-translation-custom-module-odoo-13


Implicit Exports


Odoo translates the default strings other than custom strings. In Qweb views, the translation for field can be restricted using t-translation="off"


The content included inside this block will not undergo translation. The block can be defined as shown below:


<t t-translation="off">
<!--  qweb fragments    -->
</t>


In the case of models the translation can be restricted using the attribute _translate=False via python code.


Example:


Class ModelName(models.Model):
_name = 'new.model.name'
_description = 'Model Description'
_translate = False


Unless the _translate = False is given the strings, help,_sql_constraints,_constraints and all other values are translated.


Explicit Exports

In case of explicit exports the strings should be marked explicitly for export/translation using wrapping functions.


In Python the wrapping function used is odoo._() :


	raise UserError (_("Raise Error"))


In Javascript the wrapping function is _t()


	var title = _t("This date is on the future.");


There are certain Do’s and Don'ts to be considered while performing translations:


In case of variables  specify the variable name after translation lookup:

    1. raise UserError(_("Unrecognized field %s .") % field_name)

    2. Do not split the translation in multiple lines and also do not use unwanted trailing spaces

    3. Do  not use plural words for translation as they may vary with languages


If you need any assistance in odoo, we are online, please chat with us.


cybrosys youtube

Comments

0


Leave a comment

 
Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message