How it works...

The Export Translation feature does two things: it first 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 translation already done for the selected language.

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

The CSV format can be useful to perform translations using a spreadsheet, but the format to use in the addon modules is PO files. These are expected to be placed inside the i18n subdirectory, and if so, are 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. The recipe shows how to extract both the template files and the translated language files.

In Step 4 of the previous section, we exported a template file. The --i18n-export option expects the path and the file name to export. Mind that the file extension is required to be either CSV, PO, or TGZ. This option requires the -d option, specifying the database to use. The --modules option is also needed to indicate the addon 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, that in a module is expected to have 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 exporting and including 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
18.227.111.33