Coder Social home page Coder Social logo

jekyll-date-basic-i18n's Introduction

jekyll-date-basic-i18n

This code is a basic internationalization of dates in Jekyll without plugin. You just have to copy the include, a string file and make a correct call with the liquid tag {% translated_date.html ... %}

Usage

Insert the following liquid tag in your code:

{% include translated_date.html date=A_DATE format=YOUR_FORMAT lang=THE_LANG_TO_USE %}

  • date is the date to be used (ex: page.date)
  • format is the date format you want to use (ex: "%A %-d %B %Y") following the date filter syntax. If you omit this parameter the default will be:
    • date_format if set in the _config.yml
    • "%b %-d, %Y" otherwise.
  • lang is the language to use for the translation (ex: en or fr). You have to put a file THE_LANG_TO_USE.yml in the _data/locales folder. If you omit lang parameter the default will be:
    • lang set in the Front Matter of your post or page.
    • lang set in the _config.yml

This include will replace in the format string the %a (abbreviated day name), %A (full day name), %b (abbreviated month name) and %B (full month name), by the corresponding translation found in the _data/locales/[lang].yml file.

Example

{% include translated_date.html date=post.date format="%-d %B %Y" lang="pl" %}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature")
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

If you find any issues, please feel free to contribute to repository issues

If you want to share your translation to others languages, make a Pull Request.

Context

This is the code I've designed when trying to localized my blog oncleben31.cc (Jekyll sources available at oncleben31/oncleben31-cc).

I've made it the more reusable possible with the idea to push it in minima, the default Jekyll theme. There is still an opened PR jekyll/minima#60 with this code and some strings to translate the theme.

jekyll-date-basic-i18n's People

Contributors

oncleben31 avatar domhaase avatar piecioshka avatar naxoc avatar jurajkubelka avatar krystof-k avatar httpsterio avatar abumalick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.