# Localization for Jekyll This is yet another plugin for Jekyll localization. It creates a copy of the site for each language and allows to interlink between them. ## Installation Add this line to your application's Gemfile: ```ruby group :jekyll_plugins do gem 'jekyll-locales' end ``` And then execute: $ bundle Or install it yourself as: $ gem install jekyll-locales ## Usage ### Configuration Add your locales into the `_config.yml` file, they can be anything: ```yaml locales: - es - en - ahr - brasileiro redirect: true ``` **The first locale is going to be your default locale**. If you use a redirector.html, it will be the locale it will redirector to. If you don't use a redirector, the default locale will be at the root of the site. ## Posts Put your posts into directories named after the locales, prefixed by an underscore. So for `es`, you'll need to create a `_es` directory. Move everything under `_posts` to the corresponding directory and remove it. You can add it to `.gitignore` also. To link between articles, add a hash of locales and permalinks into each post front matter: ```yaml --- locales: es: /es/hola-mundo/ en: /en/hello-world/ ahr: /ahr/ahoy-matey/ --- ``` Then you can access them by using `page.locales` in your layout. ### Pages You can translate the front matter by adding locale-specific variables in it: ```yaml --- layout: page title: Default title locales: es: title: Título en castellano permalink: pagina/ en: title: English title permalink: page/ --- ``` ### Themes To translate your theme, put the string into `_data/LANGUAGE.yml` files, where `LANGUAGE` is the name of a locale (ie. for `es`, there's a corresponding file on `_data/es.yml`). ```yaml --- lang: Castellano ``` Please note this isn't magically supported by Jekyll themes, so you may need to modify your layouts. You can then access your translations in layouts and includes like this: ```liquid {% assign locale = site.data[site.lang].lang %}