# Jekyll Language Plugin [![Gem Version](https://badge.fury.io/rb/jekyll-language-plugin.png)](http://badge.fury.io/rb/jekyll-language-plugin) > Jekyll 3.0-compatible multi-language plugin for posts, pages and includes Jekyll Language Plugin is an internationalization plugin for [Jekyll][jekyll]. It diversifies pages, posts and includes that have been optimized for the use with this plugin into different languages which are organized into subdirectories named after the language name. This plugin has been developed with user-simplicity in mind. It does not require a complex setup process unlike some other internationalization plugins. ## Features * Translates pages and posts into multiple languages * Supports all template languages that your Liquid pipeline supports. * Uses liquid tags in your HTML for including translated strings and language-specific includes. * Supports localized dates via liquid filter * Works with `jekyll serve --watch` * Supports includes translated into multiple languages ## Installation This plugin is available as a [RubyGem][ruby-gem]. 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: ``` gems: - 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`. ## Usage Every page or post, that needs to be translated must either have a `language` key or a `languages` array inside its YAML front-matter. Additionally, it may also have an `alias` key which tells the plugin to traverse one step further into the language data. So for example, if `alias` is `home` and the `language_data` configuration setting is `data.lang.%%` and the language is `en`, the plugin will look into `data.lang.en.home` for the translation keys used by the liquid tag. Of course, only pages and layouts can use the translation liquid tag but layouts used by posts can therefore benefit from an `alias`. ### Example This is a page optimized for the language plugin, `home.html`: ``` --- layout: default alias: home languages: - en - de ---
{% t description %}
``` `t` is the translation tag. In this case, it will look for `data.lang.en.home.title` and `data.lang.en.home.description` for the English language or `data.lang.de.home.title` and `data.lang.de.home.description` for the German language. To have more of a structure for larger projects, languages are divided into subdirectories. For the English language, the data file `_data/lang/en.yml` will look similar to this: ``` --- home: title: My example home page description: This is my example home page powered by the Jekyll language plugin. ``` And respectively, the German language data file, `_data/lang/de.yml` looks similar to this: ``` --- home: title: Meine Beispielhomepage description: Dies ist meine Beispielhomepage getrieben vom Jekyll-Sprachplugin. ``` Create a new file `_layouts/default.html` which will contain the default layout: ```