Useful recipes¶
pre-commit PO hooks¶
You can use pre-commit-po-hooks to check for untranslated, obsolete and fuzzy messages before each commit.
- repo: https://github.com/mondeja/pre-commit-po-hooks
rev: v1.7.3
hooks:
- id: obsolete-messages
- id: untranslated-messages
- id: fuzzy-messages
untranslated-messages....................................................Failed
- hook id: untranslated-messages
- exit code: 1
Untranslated message at docs/locale/es/index.md.po:46
obsolete-messages........................................................Passed
fuzzy-messages...........................................................Failed
- hook id: fuzzy-messages
- exit code: 1
Found fuzzy message at docs/locale/es/index.md.po:48
mdpo¶
mdpo is the core of mkdocs-mdpo-plugin. The package contains a set of programs to translate Markdown files using PO files, so you can use them directly as a command line interface or through is pre-commit hooks.
Simple README file translation with pre-commit¶
md2po2md README.md -l es fr -o locale/{lang}
- repo: https://github.com/mondeja/mdpo
rev: v0.3.85
hooks:
- id: md2po2md
files: ^README\.md
args: ['-l', 'es', 'fr', '-o', 'locale/{lang}']
๐ locale
โโโ ๐ es
โย ย โโโ ๐ README.md
โย ย โโโ ๐ README.md.po
โโโ ๐ fr
โโโ ๐ README.md
โโโ ๐ README.md.po
๐ README.md <-- only existing file before execution
Relative mkdocs-material's language selector¶
If you are using the mkdocs-material theme, you can install the mkdocs-material-relative-language-selector
plugin to make relative links between languages inside the same page and remove the current displayed language from the language selector:
pip install mkdocs-material-relative-language-selector
plugins:
- search
- material-relative-language-selector
- mdpo
plugins:
- search
- material-relative-language-selector:
root_domain: true
- mdpo