Common code for multilingual Jekyll sites
Guide that inspired this Thanks goes to @sylvaindurand.
- Add this repo as submodule to
_includes
; - Make the following:
_layouts/redirect.html
,_includes/t.html
,_includes/langbox.html
; - In all of those files put the following:
{% include jekyll-trans/<filename>.html %}
(replace<filename>
ofc). This is to dance around GitHub pages' symlink limitations; - Create folders named after languages you have, put
index.html
referencing your normal layout. In rootindex.html
reference aredirect
layout; - Use as
{% include t.html s='translation_string_id' %}
- Include
lang = {{ page.lang }}
in your<html>
tag - Put default
lang
variables over paths, i.e.:
defaults:
-
scope:
path: uk
values:
lang: uk
-
scope:
path: en
values:
lang: en
- Define translation strings as:
t:
en:
lang: 'English'
key: 'value'
key2: 'value2'
- Key
lang
is assumed to be the language's name in itself, for the purposes of the language selection UI. - For UI JavaScript include
langbox_js.html
from somewhere relevant, e.g.{% include jekyll-trans/langbox_js.html %}
from yourscripts.html
include. - Provide the EU cookie directive translations at:
t.lang.cookie_banner
.
TODO:
- blog setup i.e. links to page's translation
- make cookie thing optional