Adding Language Tags to Archives

One thing that I wanted to add to the blog is language separated archives and RSS feed. Since I follow most of the sites and blogs through RSS feeds, I want to make sure, that if there is (by any chance) anybody, that want to follow me, they can follow just what is interesting to them.

Nikola, the static site generator that I am using, has this inbuilt. As long as one uses the multiple language sites, which puts all the content in the separate language folders. I want to keep the URLs as is, and only have the language specific archives and feeds.

I am still far away from this solution, but for now, I have added the language to each blog posts. For posts, but not pages, I had language in the file name, as indicated by the Nikola. So I am using this, to now in the archives show the language next to the name.

In order to achieve this, I had to change both the template and the Post class.

In the post, I have added the following values to the init:

self.lang = ""
self.full_lang = ""
if (len(source_path.split(".")) > 2 ):
    self.lang = source_path.split(".")[-2]
    self.full_lang = self.set_lang_full_name(self.lang)

and added the following function to the post class:

def set_lang_full_name(self, lang):
    lang_dict = {
        "sl": "Slovenščina",
        "ja": "日本語",
        "en": "English"
    return lang_dict[lang]

This way, the language values were added to the post class, which means that I could access them in the templates with the ${post.lang} or ${post.full_lang} values. All I needed to do afterwards is, to make sure to change both tag.tmpl and archive.tmpl to include the new data.

Now, this does not yet solve the RSS feed and there is no filtering either, but it at least indicates the language. And allow me to see, how much more am I writing in English (588/600) compared to my mother tongue (8/600).