This module was meant to speed up and ease the translation of our localizations, you will of course need to check all translations by yourself and corrections will be needed.
The script is in two distinct parts :
translate_to_en.py
will translate the.pot
filepost_translation.py
will do all the post-processing :- Inverse terms and translation into
.pot
- Create the correct
language.po
file (with both english and foreign translations) - Replace the foreign terms by their english translations in source files
- Remove foreign language from .pot file
- Inverse terms and translation into
The only extra requirement if you want to use first part of the script that translate is libretranslate.
-
Install libretranslate. Note it will download a lot of languages, expect it to take some time.
sudo pip install libretranslate sudo libretranslate
-
Export .pot file
./odoo-bin --addons-path="addons/,../enterprise/" --database {DB_NAME} --modules='{MODULE_NAME}' --i18n-export='{MODULE_PATH}/ i18n/{MODULE_NAME}.pot' --language='{LANGUAGE_CODE}'
See here if you need more details.
-
Use script
translate_to_en.py
python3 translate_to_en.py -p {POT_FILE_PATH} -l {LANGUAGE_CODE} [-f {PO_FILE_PATH}]
You provide the script the .pot file created previously (as it is, don't inverse msgid and msgstr, next script will handle that for you) and the XX code of the foreign language. Optionally you can provide an existing PO file to keep existing translations.
Here is the list of supported languages.
-
Check all translations manually
-
Use script
post_translation.py
python3 post_translation.py -p {POT_FILE_PATH} -l LANGUAGE -m {MODULE_DATA_DIRECTORY_PATH}
Provide the .pot file with your corrections (again don't inverse msgid and msgstr, script will do it), the foreign language and the path of the
data
directory of your localization, in which the script will replace foreign terms by english-translated terms. The .pot file must be either created following this guide or follow this structure:# blahblah from po msgid "Text in foreign language" msgstr "Text in English" OR # blahblah msgid "Text already in English" msgstr "" <-- empty !
Basically when both msgid and msgstr are filled they will be reversed and translation exported to .po file, so be sure if there is English in your msgid there are no associated translation.
-
You're done !
Don't hesitate to message me on Discord if you have questions: Claire (clbr)#3668