A multilingual approach for Jekyll/Octopress sites
A detailed look into how this plugin works can be found in this blog post.
put the two Ruby files in your project's _plugins/ folder.
This plugin might not work with every third-party plugin out there. You will need to adapt them to support multiple languages.
Add a languages array to your _config.yml
# The first language is the default language of your site
languages: ['en', 'de']
This plugin supports two kinds of posts/pages:
Single-language posts/pages have a primary language that is indicated by a tag in the post's/page's front-matter:language: en
Multilingual posts/pages define their language in the filename (any language tag in the front-matter is ignored):
Of course this works with .md, .markdown and .html file extensions.
File lacking any of the above are considered to be written in the default language.
When you use this plugin, you automatically define a default language (i.e. the first language in your languages array). Sometimes, you need a page that is created at the root of your site and not in the language specific subfolders.
How do you do this? Simple: you set the language to "none".
Example: You're hosting a blog on github pages and want index page to be some kind of a gateway where visitor has to select language (or it's selected by JavaScript after analyzing Accept header reflected by some external server).
Steps:
source/index-root.html with custom welcome message and a header:---
layout: root
permalink: /index.html
language: none
---
Please select language...
source/_layouts/root.html if needed (to include head.html and so on), example:{% capture root_url %}{{ site.root | strip_slash }}{% endcapture %}
{% include head.html %}
<body>
<div class="container">
<div id="content" class="inner">{{ content | expand_urls: root_url }}</div>
</div>
</body>
</html>
Full credit should go to the Jekyll Multiple Languages Plugin. The translation code is heavily based on their work (and a copy for the most part).
Feel free to ask for help, if you encounter any issues.