Low commit activity in last 3 years
No release in over a year
Generate multiple pages for different locales based on single template.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.2
~> 0.12
~> 10.0
~> 3.0
~> 0.17
>= 1.17

Runtime

>= 0
>= 3.0
 Project Readme

Jekyll I18n MultiPage

Maintainability Test Coverage Build Status Gem Version

Generate multiple pages for different locales based on single template.

Installation

Add this line to your application's Gemfile:

gem 'jekyll_i18n_multi_page'

And then execute:

$ bundle

Add the plugin to _config.yml file:

plugins:
  - jekyll_i18n_multi_page

Usage

Declare available locales in Jekyll config _config.yml:

i18n:
  - path: /
    locale: en
  - path: /tw
    locale: zh-TW

For each entry must contain path(the output of localized page) and locale.

Define files with localized contents in _i18n folder, filenames aren't mattered. For examples:

# _i18n/my-en-site.yml
en:
  index:
    title: English title
    hello: Hello
# _i18n/my-tw-site.yml
zh-TW:
  index:
    title: 中文標題
    hello: 哈囉

page.i18n is the way to access the current localized contents, said you have a HTML named index.html:

---
---
{{ page.i18n.title }}
{{ page.i18n.hello }}

After building, the dist folder should have two files index.html and tw/index.html.

Assume you have a file named some/where/my.html you should have its path in the localization file:

# _i18n/my-en-site.yml
en:
  some:
    where:
      my:
        hello: Hello # access this text via page.i18n.hello

Use cases

For some reason, I have a page which is only available for certain locales

---
i18n_locales: ['zh-TW']
---
{{ page.i18n.hello }}

Using i18n_locales to declare the supported locales. In this example, Jekyll will build tw/index.html file only.

How to disable the features on certain pages

---
i18n_disabled: true
---

Using i18n_disabled to tell the plugin do not do anything for me.

Show/Hide something for certain locales

---
---
{% if page.i18n_locale == 'en' %}
You will see me only in the en page.
{% end %}

Translate helper

{% t index.hello %}

t tag provides a way to translate content. When you take this way, you must write a full path.

i18n global variable

i18n is a global variable provides you a way to access the root of localization.

---
i18n_disabled: true
i18n_locale: zh-TW
---
{{ i18n.some.page.title }}
{% for item in i18n.some.array %}
...
{% endfor %}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yfxie/jekyll_i18n_multi_page.

License

The gem is available as open source under the terms of the MIT License.