Translating tags and categories

9 views
Skip to first unread message

Anton Shepelev

unread,
Oct 6, 2020, 12:50:05 PM10/6/20
to nikola-...@googlegroups.com
Hello, all

Since Nikola supports the maintenance of several parallel
translations of a website, most of its generated and fixed
text can be kept in several languages. But have not found a
way to translate tags and categories. Is it possible, for
example, always to specify categoties in English:

category: cats

but have them translated into specific languages, based on a
dictionary supplied in conf.py?

Chris Warrick

unread,
Nov 15, 2020, 8:02:13 AM11/15/20
to Nikola—Discuss
This is currently not supported, but you can implement something like
this manually.

1. Put your translations in CATEGORY_TITLES.
2. Add the translations dictionary to GLOBAL_CONTEXT (eg. name it
'translated_categories')
3. When displaying tags on the post page (and in other places where
you need the translation visible), instead of displaying the tag name
directly, use translated_categories[category]

This feature could also be implemented in nikola/plugins/task/tags.py,
with a different implementation of get_classification_friendly_name.
We could take a PR to make tags and categories translatable using this
method and conf.py.

(Note that this does not affect the URLs, that would require much more work.)

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
Reply all
Reply to author
Forward
0 new messages