GithubHelp home page GithubHelp logo

kurtsson / jekyll-multiple-languages-plugin Goto Github PK

View Code? Open in Web Editor NEW
919.0 28.0 203.0 871 KB

I18n support for Jekyll and Octopress

License: MIT License

Ruby 58.91% HTML 18.93% CSS 21.14% JavaScript 1.01%

jekyll-multiple-languages-plugin's Introduction

Jekyll Multiple Languages Plugin

Jekyll Multiple Languages Plugin

Jekyll Multiple Languages is an internationalization plugin for Jekyll. It compiles your Jekyll site for one or more languages with a similar approach as Rails does. The different sites will be stored in subfolders with the same name as the language it contains.

The plugin was developed as a utility at Daresay

Badges

Build Status Gem Version

!! We are looking for more maintainers !!

Are you using this plugin? Could you test and verify incoming PRs? Please give us a shout!

Table of Contents

1. Current Release Notice

1.6.0 is the current stable release.

The support for Octopress is dropped, but the plugin should still work with it since Octopress core is Jekyll. Octopress 3 now has its own multi languages plugin: https://github.com/octopress/multilingual

2. Features

  • Supports multiple languages with the same code base.
  • Supports all template languages that your Liquid pipeline supports.
  • Uses Liquid tags in your HTML for including translated strings.
  • Compiles the site multiple times for all supported languages into separate subfolders.
  • Works with the --watch flag turned on and will rebuild all languages automatically.
  • Contains an example website, thanks to @davrandom
  • Supports translated keys in YAML format
  • Supports translated template files
  • Supports translated links

3. Installation

3.1. Using the gem

This plugin is available as a Ruby gem, https://rubygems.org/gems/jekyll-multiple-languages-plugin.

Add this line to your application's Gemfile:

gem 'jekyll-multiple-languages-plugin'

And then execute: $ bundle install

Or install it yourself as: $ gem install jekyll-multiple-languages-plugin

To activate the plugin add it to the Jekyll _config.yml file, under the plugins option:

plugins:
  - jekyll-multiple-languages-plugin

See the Jekyll configuration documentation for details.

3.2. Manually

  1. Download the repository with Git or your preferred method.
  2. Inside your Jekyll _plugins folder, create a new folder called jekyll-multiple-languages-plugin.
  3. Copy or link the directory lib, that is inside the downloaded repository, into your _plugins/jekyll-multiple-languages-plugin folder of your Jekyll project.

3.3. As a Git Submodule

If your Jekyll project is in a git repository, you can easily manage your plugins by utilizing git submodules.

To install this plugin as a git submodule:

$ git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages

To update:

$ cd _plugins/multiple-languages
$ git pull origin master

4. Configuration

4.1. _config.yml

Add the languages available in your website into your _config.yml (obligatory):

languages: ["sv", "en", "de", "fr"]

The first language in the array will be the default language, English, German and French will be added into separate subfolders.

To avoid redundancy, it is possible to exclude files and folders from being copied to the localization folders.

exclude_from_localizations: ["javascript", "images", "css"]

In code, these specific files should be referenced via baseurl_root. E.g.

<link rel="stylesheet" href="{{ "/css/bootstrap.css" | prepend: site.baseurl_root }}"/>

If you wish to avoid having the default_lang built into the root of your website, use:

default_locale_in_subfolder: true

4.2. Folder structure

Create a folder called _i18n and add sub-folders for each language, using the same names used on the languages setting on the _config.yml:

  • /_i18n/sv.yml
  • /_i18n/en.yml
  • /_i18n/de.yml
  • /_i18n/fr.yml
  • /_i18n/sv/pagename/blockname.md
  • /_i18n/en/pagename/blockname.md
  • /_i18n/de/pagename/blockname.md
  • /_i18n/fr/pagename/blockname.md

5. Usage

5.1. Translating strings

To add a translated string into your web page, use one of these liquid tags:

{% t key %}
or
{% translate key %}

This will pick the correct string from the language.yml file during compilation.

The language.yml files are written in YAML syntax which caters for a simple grouping of strings.

global:
  swedish: Svenska
  english: English
pages:
  home: Home
  work: Work

To access the english key, use one of these tags:

{% t global.english %}
or
{% translate global.english %}

You can also access translated strings by accessing the site.translations hash, this allows you to loop through your translations within Liquid using the translated string's index:

{% for item in site.translations[site.lang].my_nested_yaml_collection %}
    <p>{{ item[0] }} -> {{ item[1] }}</p>
{% endfor %}

or the translated string's assignment:

my_nested_yaml_collection:
  -
    title: First
    message: Message
  -
    title: Second
    message: Message
{% for item in site.translations[site.lang].my_nested_yaml_collection %}
   <li>
      <h2>{{ item["title"] }}</h2>
      <p>{{ item["message"] }}</p>
   </li>
{% endfor %}

5.2. Including translated files

The plugin also supports using different markdown files for different languages using the liquid tag:

{% tf pagename/blockname.md %}
or
{% translate_file pagename/blockname.md %}

This plugin has exactly the same support and syntax as the Jekyll's built in liquid tag:

{% include file %}

so plugins that extend its functionality should be picked up by this plugin as well.

5.3. Permalinks and Translating Links

To use localized pages with permalinks, you must provide a default permalink and the language specific permalinks, for example, permalink_fr for French.

To translate links, you must also add a unique namespace on the YAML front matter along with the permalinks.

Example:

---
layout:         default

namespace:     team

permalink:      /team/
permalink_fr:   /equipe/
---

And then you can use the translate link liquid tag like this:

<a href="{% tl team %}"> <!--This link will return /team if we are in the English version of the website and /fr/equipe if it's the French version</a>-->

<a href="{% tl team fr %}"> <!--This link will always return /fr/equipe</a>-->

or the longer version:

<a href="{% translate_link team %}"> <!--This link will return /team if we are in the English version of the website and /fr/equipe if it's the french version</a>-->

<a href="{% translate_link team fr %}"> <!--This link will always return /fr/equipe</a>-->

5.4. i18n in templates

Sometimes it is convenient to add keys even in template files. This works in the exact same way as in ordinary files, however sometimes it can be useful to include a different string in different pages even if they use the same template.

A perfect example is this:

<html>
  <head>
    <title>{% t page.title %}</title>
  </head>
</html>

So how can I add different translated titles to all pages? Don't worry, it's easy. The Multiple Languages plugin supports Liquid variables, as well as strings so, define a page variable in your page definition

---
layout: default
title: titles.home
---

and <title>{% t page.title %}</title> will pick up the titles.home key from language.yml

titles:
  home: "Home"

5.5. Link between languages

This plugin gives you the variables

{{ site.lang }}

and

{{ site.baseurl_root }}

to play with in your template files.

This allows you to create solutions like this:

{% if site.lang == "sv" %}
  {% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
  <a href="{{ link1 }}" >{% t global.english %}</a>
{% elsif site.lang == "en" %}
  {% capture link2 %}{{ site.baseurl_root }}{{ page.url  }}{% endcapture %}
  <a href="{{ link2 }}" >{% t global.swedish %}</a>
{% endif %}

This snippet will create a link that will toggle between Swedish and English. A more detailed description of the variables used follows:

Name Value Example
site.lang The language used in the current compilation stage en
site.baseurl Points to the root of the site including the current language http://foo.bar/en
site.baseurl_root Points to the root of the page without the language path http://foo.bar
page.url The current page's relative URL to the baseurl /a/sub/folder/page/

5.6. Creating pages

Depending on the theme, or your preferences, you need to create a "template" page in the root folder or in a folder (ex. _pages). Inside each page (in this example an about.md) you should have at least the following in the header and body:

---
layout: page
title: About
permalink: /about/
---

{% translate_file about/about.md %}

Inside each of the language folders, you should create mirror pages to provide the actual content for that language (ex. i18n/es/about/about.md). Make sure to erase the headers from those md files, or else your site will break.

5.7. Creating posts

There are no global posts. The posts are localized by language. And your posts will live in the _i18n/[lang]/_posts directory. So if, for example, you have English language on your website you should put your posts on _i18n/en/_posts directory.

5.8. Select pages to translations

Sometimes you want to generate only selected versions of the page, especially excluding default language. You can do this using languages tag.

Example:

---
permalink:      /team/
permalink_fr:   /equipe/

languages: ["fr"]
---

This generate only french version of the page.

6. License

This project is available under the MIT License.

7. Example website

This repository has an example website where you can test the plugin. After downloading the repository, get into the example directory and run: bundle install to install the newest version of Jekyll (edit the Gemfile to install another version) and all other dependencies.

Then run bundle exec jekyll serve to start the Jekyll server. Using your web browser, access the address http://localhost:4000.

7.1. Adding a new language

Imagine you want to add German pages on the test website. First, add a new language to the list of languages on _config.yml:

languages: ["it", "en", "es", "de"]

Create a new folder for the language under the _i18n folder and add a markdown file containing the translation, just like on the other language folders, and you're done.

7.2. Adding new page

Let's say you want to create an about page for the example website, you will create an about.html page on the root of the website (same place as index.html), with this:

---
layout: page
title: About
permalink: /about/
---

{% translate_file about/about.md %}

Then, create a file named about.md under _i18n/en with the English content. Repeat this for the other languages (_i18n/es/about.md ...). When running the website, visit the address http://localhost:4000/about to see the English version, http://localhost:4000/es/about for the Spanish one, etc.

8. Changelog

  • 1.8.0
    • I18n for site and Front Matter configurations @pgoltsev
  • 1.7.0
    • Option to build the default language into a subfolder
    • Configurable verbosity
    • Improved documentation
    • Removed deprecation warning
  • 1.6.1
    • Improved testing
    • Support for Jekyll 4
    • Russian examples
    • Translations rebuilt every time page is reloaded in developer mode
  • 1.6.0
    • fix: check if static_file_r_path is set
    • Missing slash before lang prefix in lang picker example
    • Updated README.md with _posts directory
    • Build translations in pre_render hook
    • If include not found, fall back to default language
  • 1.5.1
    • Fix a bug (#70) where site.static_files would be empty on subsites if exclude_from_localizations is used.
    • Some overall project enhancements and minor fixes.
    • A simple Rake task is available to test the plugin, CI services now have something to run.
  • 1.5.0
    • Enables Liquid expansions within Liquid Tags.
    • The example website post language switchers were rewritten in an algorithmic way.
  • 1.4.2
    • Exposes the site.translations hash containing the translated strings to Liquid.
  • 1.4.1
    • Fixes a bug during site regeneration where translation paths were being nested based on wrongly set Jekyll variables.
  • 1.4.0
    • Support for Jekyll 3, thanks to @pedrocarmona
    • How to create pages documentation, thanks to @elotroalex
    • Many bug fixes
    • Code refactoring, cleanup and reorganization
    • Files and folders reorganization
    • Improved and fixed issues on the example website
    • Improvements and fixes on documentations
    • Improved license files
  • 1.3.0
    • Support for localized links and custom permalinks, thanks to @jasonlemay
    • Support for excluding posts from translation, thanks to @ctruelson
  • 1.2.9
    • Bug fix when excluding files from translation, again thanks to @h6
  • 1.2.8
    • Support for excluding files from translation, thanks to @h6
  • 1.2.7
    • Support for Jekyll 2.5+, thanks to @caxy4
  • 1.2.6
    • Added fallback to default language, thanks to @agramian
  • 1.2.5
    • Fixed a bug when global variables weren't as global as expected
  • 1.2.4
    • Fixed a bug when changes in .yml files got lost during live reload.
  • 1.2.3
    • Much, much, much faster compilation when lots of translated strings.
  • 1.2.2
    • Supports translated posts in Octopress
  • 1.2.1
    • Supports writing translated posts in Jekyll
    • Supports translated .yml files in Octopress
  • 1.2.0
    • Renamed the project to jekyll-multiple-languages-plugin
  • 1.1.2
    • Support for both variables and strings in translate_file
  • 1.1.1
    • Fixed documentation
  • 1.1.0
    • Pull request that removed dirty forward slash from URLs
  • 1.0.0
    • First release

9. 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 a new Pull Request

Contributors

User Contribution
@pgoltsev version 1.8.0
@pedrocarmona support for Jekyll 3
@elotroalex added a how to create page to README
@mohamnag permalink generation bug fix
@jasonlemay support for localized links
@ctruelson support for excluding posts
@Bersch better paths
@Davrandom plugin usage example
@agramian fallback to default language
@h6 exclude files from translation
@leoditommaso update the example page

Created by

@kurtsson from Daresay (https://daresay.co)

Maintained by

Former maintainer

10. Other Language Plugins

Below is a list of other language plugins for Jekyll (2019/06/27):

Seems to be maintained:

Seems to be unmaintained / abandoned:

This plugin will in the future try to merge all pertinent features of all those plugins into it.

jekyll-multiple-languages-plugin's People

Contributors

abadzhevak8 avatar alexanderadam avatar alxckn avatar anthony-gaudino avatar bersch avatar binarious avatar buren avatar ctruelson avatar davrandom avatar dchimeno avatar elotroalex avatar figgles avatar grobmeier avatar gustavovergara avatar igorsi avatar kevinleguillou avatar kimf avatar klomontes avatar kurtsson avatar leoditommaso avatar maesitos avatar mkrajewski90 avatar pandermusubi avatar perlun avatar pgoltsev avatar pierreozoux avatar satzz avatar shushugah avatar yashrajbharti 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-multiple-languages-plugin's Issues

Breaking posts generation

Hello!
I'm using jekyll 1.4.3 and jekyll-multiple-languages-plugin 1.2.1.
When I require plugin in _plugins/plugins.rb it immediatly breaks generation of _posts/ pages.
Any ideas, why it can be so?

Plugin breaks passing a variable to an include file

This works when the plugin is not enabled:

{% include features.html param="something" %}

However, when the plugin is enabled, that variable is ignored and you basically get this:

{% include features.html %}

Different .yml files for different pages

Hello!

Rather than including different .md or .html files for page content as translate files (thus duplicating markup) would it be possible to separate out different .yml files for each of the pages while still referencing them as such: {% t page.home.section.hero.buttons.new-chart %}

Thank you for your work on this!

Undefined method 'dest='

I've added this plugin to my codebase but my project won't build anymore.
I'm using grunt to serve my jekyll site and I always get the following warning which causes the grunt task runner to exit:

jekyll 2.5.2 | Error: undefined method `dest=' for #Jekyll::Site:0x007f9392c5f940

I don't know if this is related to Grunt itself or to jekyll, I don't have enough knowledge to fix it.

Jekyll 3 incompatibility?

I just started a new Jekyll project hoping to use this plugin, but I'm getting an error right out of the box. It seems to be due to a call to read_posts, which has been deprecated in the new version.

Here is my stacktrace:

bundle exec jekyll build --trace
Configuration file: /path/to/my/jekyll/site/_config.yml
/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-multiple-languages-plugin-1.2.9/lib/jekyll/multiple/languages/plugin.rb:53:in `<class:Site>': undefined method `read_posts' for class `Jekyll::Site' (NameError)
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-multiple-languages-plugin-1.2.9/lib/jekyll/multiple/languages/plugin.rb:11:in `<module:Jekyll>'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-multiple-languages-plugin-1.2.9/lib/jekyll/multiple/languages/plugin.rb:3:in `<top (required)>'
    from /path/to/my/jekyll/site/_plugins/plugins.rb:1:in `require'
    from /path/to/my/jekyll/site/_plugins/plugins.rb:1:in `<top (required)>'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:75:in `require'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:75:in `block (2 levels) in require_plugin_files'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:74:in `each'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:74:in `block in require_plugin_files'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:73:in `each'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:73:in `require_plugin_files'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/plugin_manager.rb:18:in `conscientious_require'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:97:in `setup'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/site.rb:49:in `initialize'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:30:in `new'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:30:in `process'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary/command.rb:220:in `call'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary/command.rb:220:in `block in execute'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary/command.rb:220:in `each'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary/command.rb:220:in `execute'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary/program.rb:35:in `go'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mercenary-0.3.4/lib/mercenary.rb:22:in `program'
    from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/jekyll-3.0.0/bin/jekyll:17:in `<top (required)>'
    from /usr/local/var/rbenv/versions/2.1.2/bin/jekyll:23:in `load'
    from /usr/local/var/rbenv/versions/2.1.2/bin/jekyll:23:in `<main>'

Content sharing among languages

Great plugin!! Thank you!

I have 3 languages. 2 of them are almost identical except for a few variables in the language.yml file. Currently I solve this problem by simply using the Jekyll "include" to share the content. This works for all content files, but not for the YML files.

Is there a better way to share content among languages?
Is it possible to merge 2 yaml files? Or somehow "include" yaml content from another yaml file?

Does this all make sense? All I want to do is keep my code simple and not repeat any content. It means a lot to me :)

Thanks guys!

i18n in templates

I have :

titles:
    home: "Acceuil"
    about: "À Propos"

in _i18n/fr.yml and _i18n/en.yml (translated accordingly).

<title>{% t page.title %}</title>

Won't work. What am I missing ?

translate and loops

Hello,

I can't use the translate tag with for loops. Is it supported?

my en.yml file

symbols:
  - title: First
    message: Message
  - title: Second
    message: Message
{% for a in translate symbols %}
        <li>
            <h2>{{ a.title }}</h2>
            <p>{{ a.message }}</p>
        </li>
{% endfor %}

Easier README.md

Hi, I'm very new to jekyll (at the moment I'm working locally, migrating my textpattern website to jekyll).
I would really love to be able to manage multiple languages (it, en, es). The problem that I'm facing is that for a jekyll-newbie your readme is a bit too short. In particular -imho- is lacking some friendliness in the "usage" side. I cannot figure out how to link two posts that are the translated versions of the same post.
Maybe a minimal multilingual example website could help.

I hope I'm not alone :D
Thanks for your time
d

permalinks for the same page in other locales

I would like to find the other available links for the current page I'm in. I'm not sure how I do it. I tried something like:

{% for lang in site.languages %}
  <pre>{% tl about lang %}</pre>
{% endfor %}

But this ends up applying lang as a string, and not passing lang as the variable name.

This might be more like a Liquid issue, but what I really need here is to find the links for the other locale versions of my current page.

There might be a way to solve this writing a custom plugin extending translate-link, but I first want to confirm there's nothing more simple through the template api.


Thanks for this great tool, all the other parts are working very well the documentation is very helpful.

Wording on readme

I spent a little while trying to debug this gem it kept failing. Turns out it is because exclude_from_localizations is required, although the readme leads one to believe it's optional:

To avoid redundancy, it is possible to exclude files and folders ...

I was adding things one at a time following along with the directions. Might be worth it to add that to the readme.

page.baseurl is empty

I tried to use {{ site.baseurl }} but it comes out empty if I am using the default language. If not, it only contains e.g. /en, not http://foo.bar/en as stated in the documentation…

Again, am I missing something?

Link between translated posts

Keeping the structure of posts already discussed in here, it would be interesting as a new feature to have an automated link between translations of the same post.

@kurtsson menioned that this could be achieved by adding

def read_posts(dir)
      posts = read_things(dir, "_posts/#{self.config['lang']}", Post)

      posts.each do |post|
        if post.published && (self.future || post.date <= self.time)
          aggregate_post_info(post)
        end
      end
   end

before

end

  class LocalizeInclude < Jekyll::Tags::IncludeTag

(note: I fixed the " " and ' ').
I get this error:

Building site for default language: "it" to: /home/davrandom/Documents/jakill-test/_site
      Invalid Date: '' is not a valid datetime.
  Liquid Exception: exit in index.html

I guess because I have some posts with no date.
So if this is the case adding a if post.date != "" before the other if condition could help, but apparently it doesn't work. So atm I don't know How to fix this.

{{ post.url }} without _i18n/language/

Is it possible to generate posts without the _i18n/language/ in the path?

I'd rather prefer www.example.com/en/2014/05/05/my-post/ and www.example.com/de/2014/05/05/my-post/ instead of what I get now (www.example.com/en/_i18n/en/2014/05/05/my-post/).

Or do I just use it wrong?

Best regards

Translate index.html is possible?

I'm trying translate page with this structure.

index.html - in English
_i18n/ja/index.html - in Japanese

I have 2 questions.
.html is not target of translation?
every contents to be translated have to be under _posts ?

Is it possible to translate objects in front matter?

subnav:
  - name: subtitle.overview
    hash: overview
  - name: subtitle.examples
    hash: examples
  - name: subtitle.builder
    hash: builder
  - name: subtitle.resources
    hash: resources

This is something we're trying to do (define the navigation in the front matter) but the 'name' keys here aren't being translated (just shows up as a literal string).

How use translated permalink?

Unfortunately this doesn't work inside the permalink key inside front-matter:

---
layout: default
permalink: /titles.home/
title: titles.home

---

This return a titles.home (not translated) folder with the page inside. So my question is, how we can use and translate permalinks? Because is a no-sense translating pages and leave the permalink not translated.

Jekyll 3.0

Hi!

Is the support of Jekyll 3.x planned?

Thanks.

Possible to look up translation keys partially with a variable?

I'm trying to implement a change languages menu with languages set in the current language, but having a difficult time getting the translation key to lookup the word for the language in the current language.

The troublesome line looks like this:

  {% t languages[language] %}

Here, t matches the translate keyword, languages is part of the keyname as a plain string and language is a variable containing the current language as a string. Is it not possible to do this kind of lookup with liquid and jekyll-multiple-languages-plugin? I've scoured the manuals of both liquid and this plugin and the above way seem to be how liquid handles it, but it doesn't work with this framework. What am I doing wrong? Or is this not an intended feature or a bug?

_config.yml

...
languages: ["en", "sv"]
exclude_from_localizations: ["javascript", "images", "css"]
...

en.yml

languages:
    sv: Swedish
    en: English

langmenu.html

{% for language in site.languages %}
    {% if forloop.first %}
        <a href="/">
            {% t languages[language] %}
        </a>
    {% else %}
        <a href="/{{ language }}">
            {% t languages[language] %}
        </a>
    {% endif %}
{% endfor %}

Permalinks with ":categories" inside

I'm using the v1.2.9 of this plugin and I'm having troubles when using the ":categories" in my permalink setting inside _config.yml. The problem is that somehow the i18n and the language name (like en) are added to the categories of all the multilingual posts inside i18n directory.

english is the default language of my website and I have the following directory structure:

_18n
  |- en
  |    |- services
  |    |    |- 2015-04-20-development.md

which I wish to be structured as follows inside the output directory:

_site
  |- services
  |    |- development
  |    |    |- index.html

I have set the following setting in _config.yml file:

permalink: /:categories/:title/

however I get the following structure in output:

_site
  |- _i18n
  |    |- en
  |    |    |- services
  |    |    |    |- development
  |    |    |    |    |- index.html

I'm not sure if this is the default functionality of the jekyll which adds the i18n and en to the categories, but I expect this plugin to remove them from the categories of the post otherwise all permalinks who intend to use categories are useless.

Add SEO descriptions as well

It would be nice to have seo descriptions translated as well together with titles.
So we can use something like:

<title>{% t page.title %}</title>
<meta name="description" content="{% t page.description %}">

Posts

Hi,

all content of _posts seem to be ignored right now. When moved to _i18n, it copies the data incorrectly with _i18n ind the path name.

  • Without localization _site/news/2011-12-02-news-12
  • with plugin, the data does not arrive at all.

Expected: _site/en/news/2011-12-02-news-12.

When moved to _i18n (_i18n/en/_posts/news/2011-12-02-news-12.html) it becomes: _site/en/_i18n/en/2011-12-02-news-12. So the languages appears twice, the _18in is copied as well, and the topic subfolder is gone.

Any ideas? Maybe I am just doing it incorrectly.

Thanks,
Rene

not able to load the version.rb file since 7d6d17c

I did an update today and pull the latest 24 hours of changes.
Since then i got an error, the require on the version file doesn't work.

I also started from scratch via with the git submodule install.
That leaded to the same issue.

Here is the error:

Configuration file: /home/kyzh/opencompany.github.io/_config.yml
/usr/lib64/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- jekyll/multiple/languages/plugin (LoadError)
    from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /home/kyzh/opencompany.github.io/_plugins/ml.rb:1:in `<top (required)>'
    from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:77:in `block (2 levels) in setup'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:76:in `each'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:76:in `block in setup'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:75:in `each'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:75:in `setup'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/site.rb:26:in `initialize'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/commands/build.rb:5:in `new'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/lib/jekyll/commands/build.rb:5:in `process'
    from /home/kyzh/.gem/ruby/1.9.1/gems/jekyll-1.2.1/bin/jekyll:99:in `block (2 levels) in <top (required)>'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:155:in `run'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/runner.rb:402:in `run_active_command'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/runner.rb:78:in `run!'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/delegates.rb:11:in `run!'
    from /home/kyzh/.gem/ruby/1.9.1/gems/commander-4.1.5/lib/commander/import.rb:10:in `block in <top (required)>'

I'm not sure what to do to fix it
I tried changing the path but that didn't help much.
I also tried to copy the file in the _plugin folder, no luck there either.

Here is the steps to reproduce.
First get the project, and test it

$ git clone https://github.com/opencompany/opencompany.github.io.git
$ cd opencompany.github.io
$ jekyll serve --watch

Then initialise the plugin

$ git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages
$ cd _plugins/multiple-languages
$ git pull origin master

Finally, start the server

$ jekyll serve --watch
Configuration file: /home/kyzh/opencompany.github.io/_config.yml
/usr/lib64/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- jekyll/multiple/languages/plugin (LoadError)
...

Language switch in the example page is broken…

The really useful example page generates two translated links for the page on the index page:

http://0.0.0.0:4002/en/_i18n/it/2013/12/09/example-post.html and
http://0.0.0.0:4002/es/_i18n/it/2013/12/09/example-post.html

Both are broken in that they shouldn't carry the actual language it in them.

Plugin does not work with current master of octopress

Current master of octopress uses jekyll 0.12. This plugin however tries to use the method read_things, which is introduced in jekyll 1.4.0. Octopress master however, does not run with jekyll 1.4.0.

The readme of the plugin states, octopress is supported. How can I setup an octopress environment that works with this plugin?

[Request] Do not translate if string starts with "

My page is multi-language and I use you plugin (which is great so far).
However, when prototyping parts of the page (mainly still only in english) I use constructs like those:

title: "Security and Control over Your Money" 

jekyll attempts to translate the string, but I'd like to only translate those strings that do not start with ", like

title: security.control

Would this be possible?

Automatically build language.yml files

First of all thanks for the awesome plugin! This looks like the most comprehensive jekyll internationalization solution out there, and my small tests with it have been successful so far.

I have a large website that uses jekyll that I'm trying to internationalize. Right now I'm going to have to manually add hundreds of translation strings to these language.yml files, and so I'm wondering how hard it would be to scan all the sources for translation tags and build up an index that someone could fill in later?

I'm far from a ruby expert, but I'm trying to work out how to do this. It seems like a good start would be to use the liquid parser and the LocalizeTag on all the files in jekyll's tree and putting them in a list or a dictionary somehow, then output that to a dummy yaml file.

Any thoughts or advice on how you'd do this or actually implement this? Thanks!

Permalinks don't match where files for non-default language are placed

When using permalink: /:title.html the posts end up in the right place (in _site/postname.html for default lang and in _site/lang/postname.html for other languages). Permalinks for the default language are also correct, but for other languages post.url misses /lang. For other formats of permalink the issue will be the same.

I don't see a bug report for this yet, although gh-18 seems to be related. What would be the best way to fix this?

Keys in another folders

Hello developers.

I want to get variables from multiple files.
For example my folder structure:

|   en.yml
|   tr.yml
|   
+---en
|   +---about
|   |       about.yml
|   +---general
|   |       basic.yml
|   |       footer.yml
|   |       navigation.yml
|   \---_posts
|           2015-01-01-android-developers-days-2015-journey-has-started.markdown
|           
\---tr
    +---about
    |       about.yml
    +---general
    |       basic.yml
    |       footer.yml
    |       navigation.yml
    \---_posts
            2015-01-01-android-developers-days-2015-journey-has-started.markdown

For instance, I want to get variable slogan and an rows array from general/basic.yml.

How I can do that? Or I can't?

how to add pages?

i've been trying to add pages to the example instance following the given structure:

/_i18n/de/about/about.md

seems like i got it wrong.. any hints?

Not excluding assets path generated by jekyll-assets

I created http://stackoverflow.com/q/31325665/538400, but thought I would ask here too. I have an app that uses both this plugin and jekyll-assets. I also have this in my _config.yml:

languages: ['en', 'es']
exclude_from_localizations: ['assets']

However, when building I end up with both _site/assets and _site/es/assets. How can I get it to exclude assets directory from the additional localizations?

Here is a sample app: https://github.com/robertwbradford/jekyll-assets-and-multiple-languages

Liquid syntax error (line 19): Unknown tag 't' in _includes/post.html, included in index.html in Jekyll-3.1.2

bundle exec jekyll serve --trace
Configuration file: /home/john/blog/3rd/research/jekyll-multiple-languages-plugin/example/_config.yml
Source: /home/john/blog/3rd/research/jekyll-multiple-languages-plugin/example
Destination: /home/john/blog/3rd/research/jekyll-multiple-languages-plugin/example/_site
Incremental build: disabled. Enable with --incremental
Generating...
Liquid Exception: Liquid syntax error (line 19): Unknown tag 't' in _includes/post.html, included in index.html
/var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/tags/include.rb:132:in rescue in render': Liquid syntax error (line 19): Unknown tag 't' (Jekyll::Tags::IncludeTagError) from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/tags/include.rb:124:inrender'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/block.rb:151:in render_token' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:5:inblock in render_token_with_profiling'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/profiler.rb:80:in profile_token_render' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:4:inrender_token_with_profiling'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/block.rb:135:in block in render_all' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:ineach'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:in render_all' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/block.rb:108:inrender'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/template.rb:210:in block in render' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/template.rb:262:inwith_profiling'
from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/template.rb:209:in render' from /var/lib/gems/2.1.0/gems/liquid-3.0.6/lib/liquid/template.rb:222:inrender!'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/liquid_renderer/file.rb:28:in block (2 levels) in render!' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/liquid_renderer/file.rb:36:inmeasure_bytes'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/liquid_renderer/file.rb:27:in block in render!' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/liquid_renderer/file.rb:43:inmeasure_time'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/liquid_renderer/file.rb:26:in render!' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/renderer.rb:106:inrender_liquid'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/renderer.rb:61:in run' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/site.rb:179:inblock in render'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/site.rb:177:in each' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/site.rb:177:inrender'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/site.rb:59:in process' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/command.rb:26:inprocess_site'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/commands/build.rb:60:in build' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/commands/build.rb:33:inprocess'
from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/lib/jekyll/commands/serve.rb:34:in block (2 levels) in init_with_program' from /usr/lib/ruby/vendor_ruby/mercenary/command.rb:220:incall'
from /usr/lib/ruby/vendor_ruby/mercenary/command.rb:220:in block in execute' from /usr/lib/ruby/vendor_ruby/mercenary/command.rb:220:ineach'
from /usr/lib/ruby/vendor_ruby/mercenary/command.rb:220:in execute' from /usr/lib/ruby/vendor_ruby/mercenary/program.rb:42:ingo'
from /usr/lib/ruby/vendor_ruby/mercenary.rb:19:in program' from /var/lib/gems/2.1.0/gems/jekyll-3.1.2/bin/jekyll:13:in<top (required)>'
from /usr/local/bin/jekyll:23:in load' from /usr/local/bin/jekyll:23:in

'
john@johnlubuntu:~/blog/3rd/research/jekyll-multiple-languages-plugin/example$

folder structure in README.md

what the correct path should be in README.md ?

- /_i18/sv.yml
...
- /_i18/fr/pagename/blockname.md

or

- /_i18n/sv.yml
...
- /_i18n/fr/pagename/blockname.md

this plugin doesn't work [octopress]

This is my folder structure

.
|-- en
|   `-- _posts
|       |-- a.md
|       |-- b.md
|       |-- c.md
|       `-- d.md
|-- en.yml
|-- tr
|   `-- _posts
|       `-- t.md
`-- tr.yml

this is my index.html

{% assign post = site.posts.first %}
<article class="hentry">
  {% include article.html %}
</article><!-- /.hentry -->

The problem is when I visit http://localhost/tr, I can't see the t.md but the posts in en folder a.md b.md c.md. What is wrong?

You can see my repo at github, note that it's on gh-pages branch.

Please fix it asap.

exclude_from_localizations is not excluding `.htaccess` file

On version 1.2.9, Jekyll version 2.5.3.

I am translating my site in three languages. The exclude_from_localizations works fine for folders, .html and .txt files, except for the .htaccess file which is being copied to each of the language folders.

I tried excluding the file but the plugin seems to ignore it.

My configuration:

languages: ["default", "en" ,"de"] exclude_from_localizations: ["js", "img", "css", "humans.txt", ".htaccess", "robots.txt"]

Translate collections

Hi!

Is it possible to translate collections? Right now, I have to manage 2 separates collections and I've created a tag to link the posts together. It's working but I've got to do a lot of validation to make it work and it's not reusable if wI need to use it in another project.

Thanks!

folder example makes submodule unusable

with submodule method, I got this error while generating/serving website (jekyll serve):

/Library/Ruby/Gems/2.0.0/gems/jekyll-multiple-languages-plugin-1.2.9/lib/jekyll/multiple/languages/plugin.rb:26: stack level too deep (SystemStackError)

after deleted example folder, it works. could you please move example folder to another repo in order to make submodule work ? thanks

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.