Translation#

See also

The standard’s page for Translation

The instructions below are similar to others in ocds-extensions-translations (using the fish shell on macOS). 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/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 lang environment variable, for example:

    set lang es
    set 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.1-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
    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
      msgcat --use-first locale/$lang/LC_MESSAGES/$extension_version/**.po > $lang-(echo $extension_version | tr '/' '-').po
    end
    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 ]
      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
    end
    

Pre-translate the profile#

  1. Count untranslated messages:

    pocount --incomplete docs/locale/$lang/LC_MESSAGES | tail -n 10
    
  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
      pretranslate --nofuzzymatching -t ../../../../$lang.po ../../../../build/locale/{$f}t $f
    end
    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.