Mdview can extract a translation template from the current document, which can be handed to a translator who will create a so-called message object (MO) file.
When mdview opens a markdown file, it looks for a MO file for the current language locale following GNU gettext rules. If the MO file is found, and it includes applicable translations, mdview displays the translations of the input markdown text; otherwise it displays the original text.
Run mdview --help
for usage options.
To prepare the MO file, first run mdview --PO
to extract a translation catalog, so called PO file. The PO file contains “message identifiers” (gettext “msgid”). Each msgid is a single-line paragraph of original text, that is, a block of consecutive markdown lines joined together with space as the delimiter. Hand the PO file to a translator, who will insert translations. Then use Gettext tools to create the MO file from the PO file. This MO file will need to be installed correctly to provide runtime translations to mdview.
To enable translations start the document with:
%%textdomain YourDomain
Lines starting with tab or at least 4 spaces are not translated.
Text inside a fenced code block is not translated unless the code block start delimiter is tagged “gettext” explicitly.
```gettext
mdview --po will output this code block because its start line is "```gettext".
```
This code block
to be translated.
If some text lines should not be translated put them between matching %%nopot
yes/no tags:
%%nopot yes
`mdview --po` will not output lines between matching %%nopot tags.
%%nopot no
This text line not to be translated.