Skip to content

clbr-odoo/l10n-to-en

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

l10n-to-en

Intro + Disclaimer

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 :

  1. translate_to_en.py will translate the .pot file
  2. post_translation.py will do all the post-processing :
    1. Inverse terms and translation into .pot
    2. Create the correct language.po file (with both english and foreign translations)
    3. Replace the foreign terms by their english translations in source files
    4. Remove foreign language from .pot file

Requirements

The only extra requirement if you want to use first part of the script that translate is libretranslate.

How-to

  1. Install libretranslate. Note it will download a lot of languages, expect it to take some time.

    sudo pip install libretranslate
    sudo libretranslate
  2. 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.

  3. 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.

  4. Check all translations manually

  5. 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.

  6. You're done !

Don't hesitate to message me on Discord if you have questions: Claire (clbr)#3668

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages