Plain Jekyll

Jekyll has clearly not be designed with internationalization (i18n) in mind. This goes even one step further in ignoring non US languages. For instance, the classical incantation {{ site.time | date_to_long_string }} gives the date in English, even if LANG is configured for another language (e.g., fr_FR.UTF-8 for me). This is normal for a Ruby program, as far as I understand, but looks like a quite anti-feature if you ask me.

Localization Plugin

Fortunately, the jekyll-localization plugin solves at least the above mentioned problem. I'm not using the t filter that allows one to have language dependant content in sources but the undocumented feature of fixing the above mentioned "bug".

Localized date

When the plugin is activated (using a require 'jekyll/localization' in whatever ruby file in your _plugins directory), jekyll will try to guess the language of any page it renders. As documented, the language can be specified in the file name. For instance a file with the following content

{{ site.time | date_to_long_string }}

will be rendered to a file containing (notice the French spelling):

9 septembre 2012

Fixing the renaming

As shown above, the plugin has the annoying (undocumented) effect of swapping language codes from the middle of the file name to the end of it. As I standardized years ago on the middle for language solution, I've removed this behavior. I don't know Ruby, but it was very easy to figure out how to monkey patch (yeah!) the code in order to revert to the standard Jekyll behavior of not messing with the filenames. This is as simple as that:

module Jekyll
  # restore standard paths
  class Page

    def url(lang = nil)

    def destination(dest)

    def process(name)


Language in the file

Another undocumented feature of the plugin is that one can specify the language in the YAML front matter of the file rather than in the file name, simply by giving to the lang variable the chosen value as in the following no-lang.txt file:

lang: fr
{{ site.time | date_to_long_string }}

whose date will be rendered in French as expected. Interestingly, the file name takes precedence over the YAML front matter.

A first step only…

Fixing the date is important, but it's clearly only a very first step in achieving a multilingual jekyll website. I'll give more comments on my i18n journey in forthcoming posts.


7 September 2012