jekyll localize

A simple plugin to internationalize / localize Jekyll sites.

18
0
Ruby

h2. What it is

An “internationalization / localization”:http://en.wikipedia.org/wiki/Internationalization_and_localization plugin for “Jekyll”:http://jekyllrb.com/. This is useful if you want to translate your site into multiple languages.

h2. Getting Started

To get started, put @localize.rb@ in your @_plugins@ folder.

Add a @translations@ folder to your project with files named @en.yaml@, @es.yaml@, etc.

Put these in your translation files:

bc. global.body: “Some text goes here”

Put these in your “Liquid”:http://liquidmarkup.org/ templates:

bc. {% localize global.body %}

The language in @_config.yaml@ will be used when you build.

See the @example@ directory for a working example.

h2. Defaults

You can also (optionally) have a file in your @translations@ directory called @defaults.yaml@. This file includes translations that are used if a translation is not provided in the current language. This is useful for things like proper names, names of languages, or whatever makes sense in your project.

If a translation is not provided in either the translation file or the defaults an empty string is used.

h2. RTL

You can put @rtl: true@ in your @_config.yaml@. The @{% rtl %}@ tag will output the current setting. You could use this in a number of ways, such as conditionally loading an RTL stylesheet.

h2. Bonus

You can refer to variables in your “front matter”:https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter like this:

Translation File:

bc. cavies.title: “My Cavies”

Front Matter:

bc. title: cavies.title

Liquid Template:

bc. {% page.title %}

h2. Who uses it?

I made this project for “LearnLayout”:http://learnlayout.com. Let me know if you use it!

h2. License

“MIT”:https://github.com/incompl/jekyll-localize/blob/master/LICENSE