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¶
Install
translate-toolkit
:brew install translate-toolkit
Install
python-Levenshtein
:eval $(brew --prefix translate-toolkit)/libexec/bin/python -m pip install python-Levenshtein
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¶
Set the
globstar
option (requires Bash 4 or greater):shopt -s globstar
Set the
lang
andwip
environment variables, for example:lang=es wip=path/to/profile/from/standard
Prepare the compendia¶
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
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
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¶
Update the profile:
./script/update ./script/diff ./manage.py update
Create the POT files:
make extract
Re-create the PO files:
rm -rf docs/locale/$lang/LC_MESSAGES sphinx-intl update -p build/locale -d docs/locale -l $lang
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 ../../../..
Count untranslated messages:
pocount --incomplete docs/locale/$lang/LC_MESSAGES | tail -n 10
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
callstranslate
to translate the JSON Schema files and codelist CSV files fromschema/profile
tobuild/<lang>
, and fromschema/patched
todocs/_static/patched
.