You may have noticed that this post has multiple translations. Pelican has multilingual support for posts. It's easy to use but requires some configurations. Here are my configurations to make it work for my blog.
1. Set up URLs for different languages in pelicanconf.py
so that each language will have its own URL.
1 | DEFAULT_LANG = 'en' |
2. Write articles in different languages with lang
property in the meta. Simply set the property and write the post in corresponding language.
3. Add language selector to theme template
If needed, add language selection tags in the article template of the theme. I'm using aboutwilson
theme which doesn't contain the translation field. In this case, I added the links to the template of the theme in themes/aboutwilson/templates/article.html
right below the tags
section.
1 | {% if article.translations %} |