Import translation files

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.

Getting ready

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.

How to do it...

To import the translation terms, follow these steps:

  1. In the web client user interface, from the Settings top menu select the Translations | Import/Export | Import Translation menu option.
  2. On the Import Translations dialog, fill out the language name and the language code, and select the file to import. Finally, click on the Import button to perform the action.
    How to do it...
  3. To import from the Odoo command line interface a translation file, we must place it inside the server addons path and then perform the import:
    $ mv myfile.po ./addons/
    $ ./odoo.py -d mydb --i18n-import="myfile.po" --lang=es_E
    S
    

How it works...

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.

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

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