The usual practice to load translations is by placing the PO files inside the module's i18n
subdirectory. Whenever the addon module is installed or upgraded, the translation files are loaded and the new translated strings are added.
But there may be cases where we want to directly import a translation file. In this recipe, we will see how to load a translation file, either from the web client or from the command line.
We need to have the Developer Mode activated. If it's not, activate it in the Odoo About dialog. We are also expected to have a translation file to be imported; myfile.po
, for example.
To import the translation terms, follow these steps:
$ mv myfile.po ./addons/ $ ./odoo.py -d mydb --i18n-import="myfile.po" --lang=es_E S
Import Translation takes a PO or CSV file and loads the translation strings into the ir.translation
table.
The web client feature asks for the language name, but this is not used in the import process. It also has an overwrite option. If selected, it forces all the translations strings to be imported, even the ones that already exist, overwriting them in the process.
On the command line, the import can be done using the --i18n-import
option. It must be provided with the path to the file, relative to an addon's path directory. -d
and --language
(or -l
) are mandatory. Overwriting can also be achieved by adding the --i18n-overwrite
option to the command. Note that we didn't use the --stop-after-init
option. It is not needed, since the import action stops the server when it finishes.