vwochnik / jekyll-language-plugin Goto Github PK
View Code? Open in Web Editor NEWJekyll 3.0-compatible multi-language plugin for posts, pages and includes
License: MIT License
Jekyll 3.0-compatible multi-language plugin for posts, pages and includes
License: MIT License
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.
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?
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.
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.
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.
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 b
quits 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).
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 %}
Hi @vwochnik,
there's other language plugins for Jekyll around, and maybe you may want to unify them into a better plugin.
Here's the other plugins you may be interested in:
There's even more language plugins, but those are the ones with recent changes.
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?
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.
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.
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
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?
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.
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:
I would imagine it is just a matter of adding the extra translations but I do not want to over simplify it. Also, if that is all is needed I can start the work and submit a PR but I want to confirm that is the best way to tackle this issue.
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.
How could I get a list of pages and use the translated title form the subset?
Here the idea form the Jekyll example page:
https://github.com/jekyll/example/blob/gh-pages/_includes/header.html#L15-L21
Basically I would like to create some sort of navigation.
I'm not sure how to achieve something like this. Looks like I can't get the title through this:
{% for p in site.pages %}
{{ p }}
{% endfor %}
Also my non existent ruby skills don't help...
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?
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
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.
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!
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:in
rescue 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:in
each'
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:in
each'
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:in
require'
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:
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.
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
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:
That's the error I get:
Liquid Exception: Key h2 not found in translation. in index.html
Thanks!
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/
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.
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
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 t
or 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.
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.
Is there a better way to do that?
I am adding the upcase filter on the translation.
{% capture output %}{% t 'nav.home' %}{% endcapture %}{{ output | upcase }}
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.