Jekyll plugin for for custom locale date formatting
Jekyll Date Localization is a liquid filter plugin for formatting a date with a custom locale. The idea is based on jekyll-i18n-date however this package provides a gem-based plugin with a couple of locales already included for ease of use.
This is a simple plugin only for localizing dates, for larger scale translation capabilities check this list of plugins.
This plugin is available as a RubyGem.
There are a few ways to install the plugin (docs), e.g. by adding this line to your application's Gemfile
:
gem 'jekyll-date-localization', group: :jekyll_plugins
And then execute the bundle
command to install the gem.
You can configure the default locale in your config.yml
file:
date_locale: cs
In your markup, simply use the localize
liquid filter made available through this plugin:
{{ page.date | localize: '%d. %B %Y' }}
By default the value of date_locale
is used to select the language. Alternatively you can also directly specify the language:
{{ page.date | localize: '%d. %B %Y', 'fr' }}
For details about the formatting string, see strftime documentation. The localized entries are %b %B %a %A
.
There are a couple of built-in languages in this repository in the lib/locales directory. If you want to add your own language file or override one of the included languages, create a new *.yml
language definition file and put it in the _locales
directory of your project.
Feel free to send PRs with additional languages or improvements.
Copyright (c) 2022 Tomas Krupka
License: MIT