Provides Babel extractors and translation methods for OCDS documentation
Project description
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:
A list of tuples. Each tuple has three values:
Input files (a list of paths of files to translate)
Output directory (the path of the directory in which to write translated files)
Gettext domain (the filename without extension of the message catalog to use)
Locale directory (the path of the directory containing message catalog files)
Target language (the code of the language to translate to)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ocds-babel-0.0.5.tar.gz
.
File metadata
- Download URL: ocds-babel-0.0.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faaabbc4783db59ca0653d6ab665979f39b16b1baf109f1af72b8c17f30d43f8 |
|
MD5 | 2a734109f00b06fcce66162e5786f464 |
|
BLAKE2b-256 | 8853b2159cadfa11959e3064ce8ac5ace23193c651637d5a1c71b797ed45d81b |