Giter Site home page Giter Site logo

jekyll-language-plugin's Introduction

Jekyll Language Plugin Gem Version

Jekyll 3.0-compatible multi-language plugin for posts, pages and includes

Jekll Language Plugin

Jekyll Language Plugin is an internationalization plugin for Jekyll. It diversifies pages, posts and includes that have been optimized for the use with this plugin into different languages which are organized into subdirectories named after the language name.

This plugin has been developed with user-simplicity in mind. It does not require a complex setup process unlike some other internationalization plugins.

Features

  • Translates pages and posts into multiple languages
  • Supports all template languages that your Liquid pipeline supports.
  • Uses liquid tags in your HTML for including translated strings and language-specific includes.
  • Supports localized dates via liquid filter
  • Supports localized URLs
  • Works with jekyll serve --watch
  • Supports includes translated into multiple languages
  • Includes language and date translations for 82 languages

Installation

This plugin is available as a RubyGem.

Add this line to your application's Gemfile:

gem 'jekyll-language-plugin'

And then execute the bundle command to install the gem.

Alternatively, you can also manually install the gem using the following command:

$ gem install jekyll-language-plugin

After the plugin has been installed successfully, add the following lines to your _config.yml in order to tell Jekyll to use the plugin:

gems:
- jekyll-language-plugin

Getting Started

The repository's wiki contains detailed information on how to get started using the plugin.

Example Site

This repository contains a ready-to-use example site using this plugin in the example subdirectory. Check it out and run bundle install followed by bundle exec jekyll build to build the site.

Contribute

Fork this repository, make your changes and then issue a pull request. If you find bugs or have new ideas that you do not want to implement yourself, file a bug report.

Copyright

Copyright (c) 2015 Vincent Wochnik.

License: MIT

jekyll-language-plugin's People

Contributors

anthony-gaudino avatar karstenbriksoft avatar lubosmertak avatar mnordine avatar trevoriancox avatar vwochnik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-language-plugin's Issues

The hreflang headers in the example are incorrect.

The example website's hreflang headers will be ignored by Google and will not pass an hreflang test (e.g. https://technicalseo.com/seo-tools/hreflang/ ). This is simply because self-referencing headers are required but the sample has deliberately excluded them:

Incorrect:

{% for language in page.languages %}
  {% if page.language != language %}
    <link rel="alternate" hreflang="{{ language }}" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace_first: page.language, language }}" />
  {% endif %}
{% endfor %}

Correct:

{% for language in page.languages %}
    <link rel="alternate" hreflang="{{ language }}" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace_first: page.language, language }}" />
{% endfor %}

markdownify

It seems to me command t and also tinclude do not format/print data as markdown, the text is printed always as raw data including markdown signs, e.g.

{% t 'key_with_markdown_string_behind %}

or

{% tinclude filename.md %}

Printing markdown can be accomplished with Liquid in general like so:
{{ string_including_markdown | markdownify }}

Does and how support tor tinclude the output of markdown format?

Of course a workaround would be:
{% capture data %} {% tinclude filename.md %} {% endcapture %} {{ data | markdownify }}
But this is more complicated and would need much more code and would break the easy handling of t.

Thank you very much.

Not working with Jekyll 3.1.2

As of yesterday, this plugin no longer works with the most current version of Jekyll, 3.1.2. There are some changes in the code base that makes this plugin crash.

error in the having footer translated

I am trying to use your plugin for my website language support.
I have read the wiki, looked and copy the examples code and still I can figure out where am I doing wrong with the beggining of my code.
When building I get this error:

Liquid Exception: No language specified for current page or post. in /_layouts/default.html
jekyll 3.6.2 | Error: No language specified for current page or post.

I have published my code for better helping support. Please do a:
git clone https://github.com/alexandre1985/teste.git
to get my code that isn't working.

Slug must be first in yaml when using links / InvalidURIError

Posting here because I am unable to replicate this issue using just using yaml in a page with pure Jekyll.

The following works:

api:
  slug: api
  info: 'Try out <a href="https://example.org">the docs</a>'

While this gives error:

api:
  info: 'Try out <a href="https://example.org">the docs</a>'
  slug: api

The error is Invalid scheme format: *text* <a href="https (Addressable::URI::InvalidURIError).

Is there perhaps something with how this plugin parses the yaml that could result in this?

Better localization strings source

Hi @vwochnik,

Since the currently provided language translations are incomplete, have duplicates and errors, I believe you may be interested in using the CLDR library (http://cldr.unicode.org), it has a much more complete and correct localization data, which includes not only translation of languages, but countries, dates and much more.

CLDR is used by Google, Microsoft and many others, so you know it's good.

You can grab the most recent release here: http://unicode.org/Public/cldr/28/. It's big, so you may want to parse the XML, take what you want, and put into YAML files.
When you download the core.zip file, the XML files containing the language translations are in common/main.

There are other projects related to CLDR that can help you get the data:

Provide pre-translated strings

How do you like it if I create YAML files containing translated dates, translated language names and maybe other things for most languages?

Rails-i18n provide files with translations for dates and other things.

You will be able to include the files on the plugin or make it available to users, so they can use on their websites.

It would be something like this:

---
en-US:
  language: English
  date:
    abbr_day_names:
    - Sun
    - Mon
    - Tue
    - Wed
    - Thu
    - Fri
    - Sat
    abbr_month_names:
    - Jan
    - Feb
    - Mar
    - Apr
    - May
    - Jun
    - Jul
    - Aug
    - Sep
    - Oct
    - Nov
    - Dec
    day_names:
    - Sunday
    - Monday
    - Tuesday
    - Wednesday
    - Thursday
    - Friday
    - Saturday
    month_names:
    - January
    - February
    - March
    - April
    - May
    - June
    - July
    - August
    - September
    - October
    - November
    - December
    prompts:
      day: Day
      hour: Hour
      minute: Minute
      month: Month
      second: Seconds
      year: Year

So, if someone wants to create a menu with links for all available languages, they can query the language in the YAML and create a list like this:

English
Français
Português

If you want to, you can even automate the plugin to look for the Jekyll date liquid tag and translate the date without the user having to use another liquid tag just for it, but then in this case, the user would need to use the same language names provided by the plugin.

And if you think there's other interesting strings that could be added I will see what I can do.

cannot work in github repository

I clone the project and upload files in example directory as a github repository to my github account.
But got the following error:

The page build failed with the following error:

The tag t on line 4 in _layouts/post.html is not a recognized Liquid tag. For more information, see https://help.github.com/articles/page-build-failed-unknown-tag-error.

GitHub Pages was recently upgraded to Jekyll 3.0. It may help to confirm you're using the correct dependencies:

https://github.com/blog/2100-github-pages-now-faster-and-simpler-with-jekyll-3-0

If you have any questions you can contact us by replying to this email.

Some strange problem

Strange experience. The following work for me:

<title>{% if page.title %}{{ page.title }}{% else %}{% t 'title' %} | {% endif %}
  {% t 'site.title' %}</title>

It uses {% t 'title' %} to set a title

The following doesn't work

<title>{% t 'title' %} | {% t 'site.title' %}</title>

It throws:

Liquid Exception: Key title not found in translation.

Multidomain setup

I need to publish every language version on different domain (eg.: example.com, example.nl, example.fr). What is the correct way how to setup this plugin? Or is there any way how to achieve that with this plugin? 😄

Simple example: index.html for en, nl, fr languages.

Output will be placed into /en/index.html, /nl/index.html and /fr/index.html. If I use this solution https://github.com/vwochnik/jekyll-language-plugin/wiki/Language-Name-Liquid-Tag#offer-the-user-a-selection-of-the-available-languages to offer different language versions, it will work only when content will stay in these folders. Imagine situation when I'll map /en/ folder to example.com domain on the server. Other language version will still have URLs going to /nl/, /fr/. How ti fix this situation? Maybe I'm thinking about it in wrong way. But what is the trick how to achieve it? Thanks

Question: Differences to existing jekyll-multiple-languages-plugin?

I was just checking on how to do multilang pages with Jekyll and stumbled across different approaches and plugins.

Could you point out main differences to this plugin?:
https://github.com/screeninteraction/jekyll-multiple-languages-plugin
(The PR to support v3 will be merged soon)

Is it mainly this?

Is does not require a complex setup process unlike some other internationalization plugins.

Sorry if this is not the right place to ask, but I thought it could be interesting for others as well.

Post with no language error

When I have a post without a the language key defined in the front-matter, my site stops working properly. e.g.: when I try to list all my posts titles it only shows me one of my posts, the one without language in the front-matter.

Is this the intended behavior ? Do I have to define a language for every post or maybe I should use defaults?

tinclude error with Jekyll 3.2

tinclude does not work with the latest Jekyll version (3.2). Jekyll can not build the site and breaks with an error -> show stopper.

Liquid Exception: Could not locate the included file 'about.md' in any of ["/Users/me/Downloads/jekyll-language-plugin-master/example/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source. in about.md
jekyll 3.2.0 | Error: Could not locate the included file 'about.md' in any of ["/Users/me/Downloads/jekyll-language-plugin-master/example/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source.

This can be reproduced, e.g. with the included example of this repository:

Step1 - Update Gemfile

source 'https://rubygems.org'
gem 'jekyll', '3.2.0'
gem 'jekyll-sitemap'
gem 'jekyll-language-plugin', '1.3.2'

Step 2 - Update Gems

bundle update

Step 3 - Start Jekyll server

jekyll s

and call http://localhost:4000/de/ueber-uns.html in your browser.

I assume the reason of the new compiler error with the language plugin is this has changed in Jekyll v.3.2
IncludeTag: implement multiple load paths

Error: different prefix: "/"

Hi there !

Thanks for this plugin.
At the moment, I am configuring multi language for our Jekyll based project, so I cloned this example repo and tried to launch on my windows local.

After bundle install, when I run bundle exec jekyll serve, it says the following errors.
$ bundle exec jekyll serve Configuration file: E:/projects/jekyll/jekyll-language-plugin/example/_config.yml Source: E:/projects/jekyll/jekyll-language-plugin/example Destination: E:/projects/jekyll/jekyll-language-plugin/example/_site Incremental build: disabled. Enable with --incremental Generating... jekyll 3.2.0 | Error: different prefix: "/" and "E:/projects/jekyll/jekyll-language-plugin/example"

I would be appreciated for any help !

Thanks.

Conditional translations - possible?

Is there a way to detect if the translation string exists:

{% unless t 'title' %}
{{ site.title }}
{% endunless %}

Is there a way to assign a translated string to a parameter?

{% assign title = t 'title' %}
{% if title }
{{ title }}
{% else %}
{{ site.title }}
{% endif %}

There are other more xomplex examples where it will be useful to use or reuse translations on the page, using a varialble.

Work together with Jekyll Pagination plugin

Hi,

Is it possible to use jekyll-language-plugin in conjunction with Jekyll's pagination functionality to have links like the following:

/en/blog/
/en/blog/page2/
/ru/blog/
/ru/blog/page2/

Logging enhancement

I'm trying to switch from jekyll-multiple-languages-plugin, but I keep receiving a build exception.

  Liquid Exception: No language specified for current page or post. in _layouts/skeleton.html

I have no idea where the issue is and I'm spending a lot of time doing trial and error changes to try and fix it. It would be better if this exception was more specific about where the issue is so I can fix it and move on with my day.

No folder generated

Hello,

Thanks for the work put here. There aren't many localization projects for Jekyll out there.

I have problems getting started though.

I have gem 'jekyll-language-plugin' in my Gem file.

I added these two lines to the bottom of _config.yml

languages: ['en', 'ar']
theme: minima
plugins:
   - jekyll-language-plugin
language_data: data.lang.%%
language_includes_dir: _i18n

_layouts/home.html

---
layout: default
languages:
- en
- ar
---

However no file/folder is generated for me when I run:

bundle exec jekyll serve

What am I missing please?
Thanks,
Houman

Default locale

Hi there,
thanks for this plugin! I was wondering if it's possible to define a default locale or if you have plans to implement something like that. Or are there other ways to manage that?

Cheers!

Default permalink language not working for collections

The permalink language setting does not work with collections,

Scenario a.) default permalink is set in _config.yml

collections:
  mycollection:
    output: true

defaults:
  - scope:
      path: ""
      type: "posts"
    values:
      path: "_posts"
      layout: post
      permalink: /:language/:categories/:path/
  - scope:
      path: ""
      type: mycollection
    values:
      layout: page
      permalink: /:language/:collection/:title/
      subset: mycollection

jekyll bquits with an error

Error: could not read file /Users/me/Development/www/_mycollection/master.md: undefined method `language' for #<Jekyll::Drops::UrlDrop:0x007fe40201c028>
jekyll 3.1.2 | Error:  undefined method `language' for #<Jekyll::Drops::UrlDrop:0x007ff375078508>

Scenario b) permalink in each file - it works when the permalink is set in each collection file in the YAML (which is additional work).

Example: bundle install

The example relies on 1.1.6. so I get:

bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Could not find gem 'jekyll-language-plugin (= 1.1.6) ruby' in any of the gem sources listed in your Gemfile or available on this machine.

After changing it to 1.1.7 it works fine.

native language names

It appears the only way to print a language is using {% tl language %}
While it may seem reasonable to do that it actually requires the visitor of a webpage to understand the language he's on. A chinese visitor on an english page needs to know that "Chinese" refers to his language. It would really help if there was a tln (translate language native) tag that renders "de" as Deutsch and "en" as English. Wikipedia does it right already.

Default language

Hi, thanks for this awesome plugin. There is a way to set a default language? i want to have a lang subfolder only for the other languages. Example with this languages languages: ['en', 'de', 'fr'] i want this output

index.html
/de
/fr

instead of

index.html
/en
/de
/fr

Links always point back to first language

I'm trying to use the link tag outlined here - https://jekyllrb.com/docs/templates/#link

<a href="{{ site.baseurl }}{% link support/index.md %}">{% t 'ui-text.navbar.support' %}</a>

The problem I'm finding is when viewing my fr-ca page, the hyperlink always points back to the first language I setup, en-us. Both hyperlinks always equal http://localhost:4000/en-us/support/. Do you have any recommendations on this?

Duplicate posts are listed

In jekyll-language-plugin/example/index.html there is the following code:

<ul>
{% for post in site.posts %}
  {% if post.language == page.language %}
    <li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li>
  {% endif %}
{% endfor %}
</ul>

When rendered on my system, the Welcome to Jekyll! post is displayed twice on both the English and German pages. On the German page, the Willkommen bei Jekyll! post is displayed once.

I am using Jekyll 3.0.0 on Mac OS X El Capitan 10.11.2 (15C50).

Thank you.

Build error

Hello all,

I am sorry but I work with the last version of Jekyll and I still got error on a build:

/Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:inrescue in block (2 levels) in require': There was an error while trying to load the gem 'jekyll-language-plugin'. (Bundler::GemRequireError)
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in block (2 levels) in require' from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:ineach'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in block in require' from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:ineach'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in require' from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler.rb:99:inrequire'
from /Library/Ruby/Gems/2.0.0/gems/jekyll-3.0.3/lib/jekyll/plugin_manager.rb:39:in require_from_bundler' from /Library/Ruby/Gems/2.0.0/gems/jekyll-3.0.3/bin/jekyll:13:in<top (required)>'
from /usr/local/bin/jekyll:22:in load' from /usr/local/bin/jekyll:22:in

'`

I read the "Getting Started" in a wiki page and I copy/past this code in my Gemfile :
`gems:

  • jekyll-language-plugin`
  • add this :
    language_data: data.lang.fr language_includes_dir: _i18n

Has you see, I would like a translate a date in French from the Liquid Markup. I do not have (and do not need yet) a folder called _i18n. I just tried create this folder with fr subfolder but still same.

Some help will be appreciated, thanks.

How to translate my Includes?

Hello!
I am having problems in translating my includes...
I do exactly as I do in pages: put the vector of languages and which languages I want to translate.
That's the front matter of my includes:


languages:

  • pt
    subset: metrics

That's my pt.yml file:
image

That's the error I get:
Liquid Exception: Key h2 not found in translation. in index.html

Thanks!

SEO improvements for generated URLs (filename/permalink)

As you told here, the created filename is based on the name of the file I create in the root folder of the project.

For example about.html will create:
/en/about.html
/de/about.html

Form an SEO point of view this would be nicer if the generated file could use a slug from the lang subset.

For a simple page this isn't a big deal, but if you want to optimise for a certain word/product/service this would be important. For example:
/en/hauskeeping-in-uk.html
/de/hausreinigung-in-deutschland.html

On the other hand this might be too complex when it comes to posts.
Maybe this is getting out of scope now... but I wanted to bring this up. What do you think?

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.