Translation engine in odoo

15
Translation Engine in Odoo Ranjit Pillai (rpi-odoo) Jr. Application Engineer Tiny ERP Pvt. Ltd.

Transcript of Translation engine in odoo

Page 1: Translation engine in odoo

Translation Engine in Odoo

Ranjit Pillai (rpi-odoo)Jr. Application EngineerTiny ERP Pvt. Ltd.

Page 2: Translation engine in odoo

Agenda

● Architecture of Translation Engine

● Load Translation from po file

● Export Translation into pot file

● About Transifex

● Integrate Translation Web Service: Gengo

Page 3: Translation engine in odoo

Architecture of Translation Engine

Odoo Translation

Engine(ir.translation)

po file pot file

Webpage/View

Transifex(Translator)

Import/Load Export

Template FileTranslated File

Language in context

Translated View

UTW

TW

❖ UTW - Untranslated Words❖ TW - Translated Words

Page 4: Translation engine in odoo

Load Translation

● Load the particular language Settings>Translation>Load a Translation

● Change the user’s language Preferences>Language

Odoo Translation

Engine(ir.translation)

po fileImport/Load

Webpage/View

Language in context

Translated View

Page 5: Translation engine in odoo

Export Translation into POT file

● To generate .pot file go to Settings>Translation>Import/Export>Export Translation

Odoo Translation

Engine(ir.translation)

pot fileExport

Page 6: Translation engine in odoo

Translation Export Types

Implicit exports

● Odoo automatically exports translatable strings like:○ In non-QWeb views, all text nodes are exported as well as the content of the “string”, “help”,

“sum”, “confirm” and “placeholder” attributes.

○ In QWeb templates, all text nodes are exported except inside t-translation=’off’ blocks, the content of the “title”, “alt”, “label” and “placeholder” attributes are also exported.

○ for class:`openerp.fields.Field`, unless their field is marked with “translate = False”: their “string” and “help” attributes are exported.

○ If “selection” is present and a list (or tuple), it is exported.

○ help/error messages of `openerp.models.Model._constraints` and `openerp.models.Model._sql_constraints` are exported.

Page 7: Translation engine in odoo

Translation Export Types(Cont.)

Explicit exports

● When it comes to more "imperative" situations in Python code or Javascript code, Odoo cannot automatically export translatable terms so they must be marked explicitly for export. This is done by wrapping a literal string in a function call.

○ In Python, the wrapping function is :`openerp._`■ title = _("Bank Accounts")

○ In JavaScript, the wrapping function is generally :`openerp.web._t`■ title = _t("Bank Accounts")

Page 8: Translation engine in odoo

Structure of translation terms

Note.pot

fr.po (inside note/i18n)

ir.translationmodel

● Example of type = model:

Page 9: Translation engine in odoo

Structure of translation terms(cont.)

Stock.pot

fr.po (inside stock/i18n)

ir.translationmodel

● Example of type = code:

● Other types are selection, constraint and sql_constraint

Page 10: Translation engine in odoo

Directory Structure of i18n in Odoo

POT files are basically the template files for PO files. It will have all the translation strings (the msgstr parts) left empty.

PO files are the files which contain the actual translations. Each language will have its own PO file, for example, for French there would be a fr.po file, for german there would be a de.po and so on..

Page 11: Translation engine in odoo

Translating Odoo with Transifex

● The easiest way to translate Odoo is to use the dedicated Translation interface on Transifex.

● Transifex provides a web-based translation interface, which can be used to translate.

● Translation Teams on Transifex○ Every language is managed by a dedicated translation team. Anyone is free to join any translation

team at any point. Within each team, members can have different roles:■ Translator: free to join, can submit translation suggestions (this is your role when you initially join a

team)

■ Reviewer: can approve translation suggestions from Translators.

■ Coordinator: can manage the members of the team and appoint Reviewers.

Page 12: Translation engine in odoo

Translating Odoo with Transifex(cont.)

● Architecture of Transifex

<module>.pot Transifex

<lang>.po

<lang>.po

<lang>.po

<lang>.po

Page 13: Translation engine in odoo

Gengo Translation

● Gengo is a web-based human translation platform.● In Odoo, Gengo is used to translate the text of the Website.

Send Words

Receive TranslatedWords

Page 14: Translation engine in odoo

Thank You !!!

Page 15: Translation engine in odoo

References

References:

● https://github.com/odoo/odoo/wiki/Translations● https://www.odoo.

com/documentation/master/reference/translations.html

Useful Links:

● Transifex Tutorial : http://docs.transifex.com/tutorials/client/● Odoo & Transifex : https://www.transifex.com/odoo/public/● GNU gettext : http://www.gnu.

org/software/gettext/manual/gettext.html