mdpo.md2po2md package
Markdown to PO file to Markdown translator.
- mdpo.md2po2md.markdown_to_pofile_to_markdown(langs, input_paths_glob, output_paths_schema, extensions=['collapse_whitespace', 'tables', 'strikethrough', 'tasklists', 'latex_math_spans', 'wikilinks'], command_aliases=None, location=True, debug=False, po_wrapwidth=78, md_wrapwidth=80, po_encoding=None, md_encoding=None, include_codeblocks=False, md2po_kwargs=None, po2md_kwargs=None, _check_saved_files_changed=False, no_obsolete=False, no_fuzzy=False, no_empty_msgstr=False)
Translate a set of Markdown files using PO files.
- Parameters:
langs (list) – List of languages used to build the output directories.
input_paths_glob (str) – Glob covering Markdown files to translate.
output_paths_schema (str) –
Path schema for outputs, built using placeholders. There is a mandatory placeholder for languages:
{lang}
; and one optional for output basename:{basename}
. For example, for the schemalocale/{lang}
, the languages['es', 'fr']
and aREADME.md
as input, the next files will be written:locale/es/README.po
locale/es/README.md
locale/fr/README.po
locale/fr/README.md
Note that you can omit
{basename}
, specifying a directory for each language withlocale/{lang}
for this example. Unexistent directories and files will be created, so you don’t have to prepare the output directories before the execution.extensions (list) – md4c extensions used to parse markdown content, formatted as a list of ‘pymd4c’ keyword arguments. You can see all available at pymd4c documentation.
command_aliases (dict) – Mapping of aliases to use custom mdpo command names in comments. The
mdpo-
prefix in command names resolution is optional. For example, if you want to use<!-- mdpo-on -->
instead of<!-- mdpo-enable -->
, you can pass the dictionaries{"mdpo-on": "mdpo-enable"}
or{"mdpo-on": "enable"}
to this parameter.location (bool) – Store references of top-level blocks in which are found the messages in PO file
#: reference
comments.debug (bool) – Add events displaying all parsed elements in the extraction process.
po_wrapwidth (int) – Maximum width for PO files.
md_wrapwidth (int) – Maximum width for produced Markdown contents, when possible.
po_encoding (str) – PO files encoding.
md_encoding (str) – Markdown files encoding.
include_codeblocks (bool) – Include codeblocks in the extraction process.
md2po_kwargs (dict) – Additional optional arguments passed to
markdown_to_pofile
function.po2md_kwargs (dict) – Additional optional arguments passed to
pofile_to_markdown
function.no_obsolete (bool) – If
True
, check for obsolete entries in PO files.no_fuzzy (bool) – If
True
, check for fuzzy entries in PO files.no_empty_msgstr (bool) – If
True
, check for emptymsgstr
entries.