mkdocs-mdpo-plugin¶
Translations for Mkdocs using PO files, fully customizable. Compatible with mkdocs-material, based on mdpo.
Install¶
pip install mkdocs-mdpo-plugin
Usage¶
Enable the plugin in your mkdocs.yml
:
plugins:
- mdpo
Minimal configuration¶
With mkdocs-material¶
theme:
name: material
language: en
extra:
alternate:
- name: English
lang: en
- name: EspaΓ±ol
link: es
lang: es
plugins:
- mdpo
Standalone¶
plugins:
- mdpo:
languages:
- en # first language is the original
- es
Both previous configurations will create the same layout of files building the documentation. Given the next layout in a docs/
directory:
π docs
βββ π index.md
After the build, you will get:
π docs
βββ π es
βΒ Β βββ π index.md.po
βββ π index.md
Just translate the strings in docs/es/index.md.po
into Spanish, build again with mkdocs build
and the site/
directory will look like:
π site
βββ π 404.html
βββ π assets
βΒ Β βββ π images
βΒ Β βββ π javascripts
βΒ Β βββ π stylesheets
βββ π es
βΒ Β βββ π index.html
βββ π index.html
βββ π sitemap.xml
βββ π sitemap.xml.gz
How does it works¶
mkdocs-mdpo-plugin is based in mdpo which is a program to translate CommonMark compliant Markdown content using PO files.
Tip
See also the traditional approach for Markdown translations and mdpo approach.
As with mkdocs you write Python-Markdown's implementation of Markdown, mkdocs-mdpo-plugin uses the xml.etree.ElementTree
to translate the rest messages of custom HTML created by the extensions. This is the reason why for some of them the translation process must be adjusted somewhat to be supported correctly (see Extensions support).
Known limitations¶
- The command
mkdocs serve
doesn't work if you store the PO files inside the documentation folder. Use another layout like the explained inlocale_dir
configuration. - Currently, edited messages are not marked as fuzzy like xgtettext does.