Translation

See also

The standard’s page for Translation

The instructions below are similar to others in ocds-extensions-translations. They will, at minimum, pre-translate the text from the unextended schema and codelists.

Pre-translate a profile

One-time setup

  1. Install translate-toolkit:

    brew install translate-toolkit
    
  2. Install python-Levenshtein:

    eval $(brew --prefix translate-toolkit)/libexec/bin/python -m pip install python-Levenshtein
    
  3. Clone the standard and ocds-extensions-translations repositories into the same parent directory:

    git clone git@github.com:open-contracting/standard.git
    git clone git@github.com:open-contracting/ocds-extensions-translations.git
    

Each-time setup

  1. Set the globstar option (requires Bash 4 or greater):

    shopt -s globstar
    
  2. Set the lang and wip environment variables, for example:

    lang=es
    wip=path/to/profile/from/standard
    

Prepare the compendia

  1. Change to the standard directory, then prepare a compendium:

    git checkout 1.1
    git pull --rebase
    msgcat --use-first docs/locale/$lang/**/*.po > $wip/$lang-standard.po
    git checkout 1.2-dev
    
  2. Change to the ocds-extensions-translations directory, then prepare a compendium. For example, for OCDS for PPPs 1.0.0-beta3:

    git checkout main
    git pull --rebase
    tx pull -w 20 -f -a
    for extension_version in bids/v1.1.5 charges/master documentation_details/master finance/master location/v1.1.5 metrics/1.1 milestone_documents/v1.1.5 performance_failures/master project/master risk_allocation/master shareholders/master signatories/master tariffs/1.1 ppp/master; do
      msgcat --use-first locale/$lang/LC_MESSAGES/$extension_version/**/*.po > $lang-$(echo $extension_version | tr '/' '-').po
    done
    msgcat --use-first $(ls $lang-*.po) > $wip/$lang-extensions.po
    rm -f $lang-*.po
    
  3. Change to the profile’s directory, then prepare a compendium:

    if [ -d docs/locale/$lang/LC_MESSAGES ]; then
      msgcat --use-first $lang-standard.po $lang-extensions.po docs/locale/$lang/**/*.po > $lang.po
    else
      msgcat --use-first $lang-standard.po $lang-extensions.po > $lang.po
    fi
    

Pre-translate the profile

  1. Update the profile:

    ./script/update
    ./script/diff
    ./manage.py update
    
  2. Create the POT files:

    make extract
    
  3. Re-create the PO files:

    rm -rf docs/locale/$lang/LC_MESSAGES
    sphinx-intl update -p build/locale -d docs/locale -l $lang
    
  4. Pre-populate the PO files:

    cd docs/locale/$lang/LC_MESSAGES
    for f in **/*.po; do
      pretranslate --nofuzzymatching -t ../../../../$lang.po ../../../../build/locale/${f}t $f
    done
    cd ../../../..
    
  5. Count untranslated messages:

    pocount --incomplete docs/locale/$lang/LC_MESSAGES | tail -n 10
    
  6. Clean up:

    rm -f $lang-standard.po $lang-extensions.po $lang.po
    

Technical implementation of translation

See also

The standard’s page for Technical implementation of translation

  • babel_ocds_codelist.cfg indicates the codelist CSV files in the consolidated extension and the patched OCDS (schema/*/codelists/*.csv) from which to extract strings to translate.

  • babel_ocds_schema.cfg indicates the JSON Schema files in the consolidated extension and the patched OCDS (schema/*/*-schema.json) from which to extract strings to translate.

  • conf.py calls translate to translate the JSON Schema files and codelist CSV files from schema/profile to build/<lang>, and from schema/patched to docs/_static/patched.