Gettext Tools
The GNU gettext tools help in producing, using, and updating the translation files. Odoo
uses the gettext-like method ‘underscore’ _() for speeding up the
translations. In the code, we can use it to mark the string literals, those to be
translated, with the language in the current context. We have to import the _ from odoo
packages to use it in the python code.
Once we import it, we can write the string literals within _(), which will include them
in the translation file.
Now, export the translation file(PO file) for a language for the corresponding module.
We can see that the string literal to be translated is available in the PO file. The
untranslated string will be given in the msgid. We can add the
translated string for the corresponding language in msgstr.
Once we complete adding/ updating the translations, we can add them to Odoo in 2 ways. We
can import the translation file manually to add/ update the translations in Odoo.
If we need to update the translations automatically with the module, create a new
directory i18n inside the module and add our translation files to it.
This is very useful when we release the apps/ modules that support multiple languages.
The file name for the translation files will be the ISO code of the language in
Odoo(E.g. fr_CA.po). The translation template from Odoo is also added to the directory
with the file name as module name(E.g. point_of_sale.pot).
The translations will be added to Odoo with the modules and will be loaded automatically
on activating the languages.