Skip to main content

Provides Babel extractors and translation methods for OCDS documentation

Project description

PyPI version Build Status Dependency Status Coverage Status

This Python package provides Babel extractors and translation methods for OCDS documentation.

Examples

Babel extractors

Babel extractors can be specified in configuration files. For example:

[ocds_codelist: schema/*/codelists/*.csv]

in babel_ocds_codelist.cfg, or:

[ocds_schema: schema/*/*-schema.json]

in babel_ocds_schema.cfg.

Translation methods

In the Sphinx build configuration file (conf.py), you can use translate to translate codelist CSV files and JSON Schema files:

import os
from glob import glob
from pathlib import Path

from ocds_babel.translate import translate


def setup(app):
    basedir = Path(os.path.realpath(__file__)).parents[1]
    localedir = basedir / 'locale'
    language = app.config.overrides.get('language', 'en')

    translate([
        (glob(str(basedir / 'schema' / '*-schema.json')), basedir / 'build' / language, 'schema'),
        (glob(str(basedir / 'schema' / 'codelists')), basedir / 'build' / language, 'codelists'),
    ], localedir, language)

translate automatically determines the translation method to used based on filenames. The arguments to translate are:

  1. A list of tuples. Each tuple has three values:

    1. Input files (a list of paths of files to translate)

    2. Output directory (the path of the directory in which to write translated files)

    3. Gettext domain (the filename without extension of the message catalog to use)

  2. Locale directory (the path of the directory containing message catalog files)

  3. Target language (the code of the language to translate to)

  4. Optional keyword arguments to replace {{marker}} markers with values, e.g. version='1.1'

Methods are also available for translating extension.json and for translating Markdown-to-Markdown.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocds-babel-0.0.3.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file ocds-babel-0.0.3.tar.gz.

File metadata

  • Download URL: ocds-babel-0.0.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for ocds-babel-0.0.3.tar.gz
Algorithm Hash digest
SHA256 603038c0ee2897e786acaf1fb41682eb936ca9a49a41cf7d6a1725b1c2aef3d7
MD5 feb9356f329f0c5d589bbeb06595e2bc
BLAKE2b-256 7ffa6c66fc9b15b612acb6b93857b05cd6b4b6ecefba3e6f427e6c7006d7eba5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page