Skip to content
Hendrik Bursian edited this page Mar 18, 2018 · 3 revisions

Installation

This plugin is available as a RubyGem.

Add this line to your application's Gemfile:

gem 'jekyll-language-plugin'

And then execute the bundle command to install the gem.

Alternatively, you can also manually install the gem using the following command:

$ gem install jekyll-language-plugin

After the plugin has been installed successfully, add the following lines to your _config.yml in order to tell Jekyll to use the plugin:

plugins:
- jekyll-language-plugin

Configuration

Two additional configuration keys must be present in your _config.yml in order for the plugin to work properly:

language_data: data.lang.%%
language_includes_dir: _i18n

The first key, language_data, tells the plugin where it can find the translation data used by the liquid tag. %% is a placeholder for the language name. So, if the language is en, the plugin will look into data.lang.en.

It is entirely up to you how you are structuring your Jekyll data. You can have a file lang.yml inside your _data directory or you can have a lang subdirectory inside your _data directory containing en.yml or en.json.

Theoretically, you could also have an external plugin provide language data by changing this setting to the reference object provided by the plugin. If the plugin populates an object with the Jekyll-internal reference site.external_plugin.lang, the language_data configuration setting should be external_plugin.lang.%%.

The second key, language_includes_dir, works similar to Jekyll's includes_dir configuration setting. By default, it is set to _i18n. This is where language-specific includes are stored. For each language, there is one sub-directory. The tinclude liquid tag then picks the appropriate sub-directory for the language to render.