jekyll-task-i18n is a preprocessor for Jekyll to support i18n.
There are some i18n softwares for Jekyll that are implemented as Jekyll plugin such as jekyll-localization and jekyll-i18n. jekyll-task-i18n uses preprocessor approach instead of Jekyll plugin. This approach has the following advantages:
- You can use i18n feature on GitHub pages.
- You don't mark translate target texts up in your source.
You can't use Jekyll plugins on GitHub Pages. So you can't use Jekyll plugin based approaches too.
jekyll-localization uses {{'translate target content' | t: 'translated content' }} markup. jekyll-i18n uses {%t Your translated content %} markup.
jekyll-task-i18n extracts translate target content from source as preprocessor. So you don't need to mark your source up.
TODO
Create the following Gemfile:
source "https://rubygems.org/" gem "jekyll-task-i18n" Create the following Rakefile:
require "bundler/setup" require "jekyll/task/i18n" Jekyll::Task::I18n.define do |task| # Set translate target locales. task.locales = ["ja", "fr"] # Set all *.md texts as translate target contents. task.files = Rake::FileList["**/*.md"] # Remove internal files from target contents. task.files -= Rake::FileList["_*/**/*.md"] # Remove translated files from target contents. task.locales.each do |locale| task.files -= Rake::FileList["#{locale}/**/*.md"] end end Add the following line to _config.yml:
exclude: ["Gemfile", "Gemfile.lock", "Rakefile"] Install dependency softwares:
% bundle Here is a work-flow to translate one documentation in English:
- Run
rake. - Translate
_po/${YOUR_LOCALE}/${PATH_TO_TARGET_FILE}.edit.po. - Run
rake. - Run
jekyll server. - Confirm
_site/${YOUR_LOCALE}/${PATH_TO_TARGET_FILE}.html. - Commit
_po/${YOUR_LOCALE}/${PATH_TO_TARGET_FILE}.po(not.edit.po) and${YOUR_LOCALE}/${PATH_TO_TARGET_FILE}.md.
Here is an example to translate overview/index.md into Japanese.
Run rake:
% rake Translate _po/ja/overview/index.edit.po:
% gedit _po/ja/overview/index.edit.po Note: You can use PO editor instead of text editor. For example, Emacs's po-mode, Vim, Gtranslator, Lokalize and so on.
Run rake:
% rake Run jekyll server:
% jekyll server & Confirm _site/ja/overview/index.html:
% firefox http://localhost:4000/ja/overview/index.html Commit _po/ja/overview/index.po and ja/overview/index.md:
% git add _po/ja/overview/index.po % git add ja/overview/index.md % git commit % git push LGPLv2 only. See LICENSE.txt for detail.