The GNU gettext tools play a crucial role in creating, employing, and maintaining translation files. Odoo employs gettext methods like, underscore function _() to facilitate accelerated translations. This method allows developers to annotate string literals in the code that need translation within the context of the current language. Importing _ from the Odoo packages is necessary to utilize this approach in Python code.
Once it is imported, we can write the string literals within _(), which will include them in the translation file.
Export the translation of the language for the corresponding module.
The string literal intended for translation is observable in the PO file, with the untranslated string provided under msgid. The translated string for the respective language can be added in msgstr.
After adding the translations we can incorporate this with the module in two ways.One of them is importing the translated file.
Another method is adding the translation files within the i18n directory of the module and translations will be automatically updated.This practice is very beneficial when releasing apps or modules supporting multiple languages. The translation file is named using 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. base.pot).
The translations will be added to the modules and will be loaded automatically on activating the languages.