How it works...

The Export Translation feature does two things: extracts the translatable strings from the target modules, adding the new ones in the ir.translation model, and then creates a file with the translation terms. This can be done both from the web client and the command-line interface.

When exporting from the web client, we can choose to either export an empty translation template, that is, a file with the strings to translate along with empty translations, or export a language, resulting in a file with the strings to translate, along with the translation for the selected language.

The file formats that are available are CSV, PO, and TGZ. The TGZ file format exports a compressed file that contains a <name>/i18n/ directory structure with the PO or POT file.

The CSV format can be useful for performing translations using a spreadsheet, but the format to use in the add-on modules is PO files. These are expected to be placed inside the i18n subdirectory. They are then automatically loaded once the corresponding language is installed. When exporting these PO files, we should export only one module at a time. The PO file is also a popular format supported by translation tools, such as Poedit.

Translations can also be exported directly from the command line, using the --i18n-export option. This recipe shows how to extract both the template files and the translated language files.

In step 4 of this recipe, we exported a template file. The --i18n-export option expects the path and the file name to export. Bear in mind that the file extension is required to be either CSV, PO, or TGZ. This option requires the -d option, which specifies the database to use. The --modules option is also needed to indicate the add-on modules to export. Note that the --stop-after-init option is not needed, since the export command automatically returns to the command line when finished.

This exports a template file. The Odoo module expects this exported template in the i18n folder with the .pot extension. When working on a module, after the export operation, we usually want to move the exported PO file to the module's i18n directory with a <module>.pot name.

In step 5, the --language option was also used. With it, instead of an empty translation file, the translated terms for the selected language were also exported. One use case for this is to perform some translations through the web client user interface using the Technical Translation feature, and then export and include them in the module.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset