Step 1 uses commands from the gettext toolbox to create a translation compendium for the chosen language—Spanish, in our case. It works by finding all the es_ES.po files in the Odoo code base, and passing them to the msgcat command. We use the --use-first flag to avoid conflicting translations (there are a few in the Odoo code base). The result is passed to the msgattrib filter. We use the --translated option to filter out the untranslated entries and the --no-fuzzy option to remove fuzzy translations. We then save the result in odoo_es.po.
Step 2 of the preceding section calls odoo.py with the --i18n-export option. You need to specify a database on the command line, even if one is specified in the configuration file and the --modules option, with a comma-separated list of modules to export the translation.
Step 3 creates a new translation file by using existing translated values found in the compendium. The msgmerge command is used with the --compendium option to find the msgid lines in the compendium files, matching those in the translation template file generated in step 2. The result is saved in the es_ES.po file.
If you have a preexisting .po file for your add-on with translations you would like to preserve, you should rename it and replace the /dev/null argument with this file. The renaming procedure is required to avoid using the same file for input and output.