Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
* Enables Liquid expansions within Liquid Tags.
Browse files Browse the repository at this point in the history
* The example website post language switchers were rewritten in an algorithmic way.
  • Loading branch information
Anthony-Gaudino committed Aug 14, 2016
1 parent 2c78dde commit 532c713
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 72 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -40,7 +40,7 @@ Table of Contents

## 1. Current Release Notice

1.4.1 is the current stable release.
1.5.0 is the current stable release.

Users that update from older versions to 1.4.0 or newer must change their `_config.yml` for the plugin to be loaded. Please see the `Installation` section bellow for the new string used to load the plugin.

Expand Down Expand Up @@ -357,6 +357,9 @@ Then, create a file named `about.md` under `_i18n/en` with the English content.


## 8. Changelog
* 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
Expand Down
7 changes: 4 additions & 3 deletions example/_i18n/en.yml
@@ -1,11 +1,12 @@
global:
italian: Italiano
english: English
spanish: Español
tagline: English
about: About
twitter: Twitter
github: GitHub
langs:
it: Italiano
en: English
es: Español
pages:
example: example
includeexample: The following text is a Jekyll include liquid tag parameter
Expand Down
7 changes: 4 additions & 3 deletions example/_i18n/es.yml
@@ -1,11 +1,12 @@
global:
italian: Italiano
english: English
spanish: Español
tagline: Español
about: Sobre
twitter: Twitter
github: GitHub
langs:
it: Italiano
en: English
es: Español
pages:
example: Ejemplo
includeexample: El siguiente texto es un parámetro de Jekyll include liquid tag
Expand Down
7 changes: 4 additions & 3 deletions example/_i18n/it.yml
@@ -1,11 +1,12 @@
global:
italian: Italiano
english: English
spanish: Español
tagline: Italiano
about: Riquardo
twitter: Twitter
github: GitHub
langs:
it: Italiano
en: English
es: Español
pages:
example: Esempio
includeexample: Il testo che segue è un parametro di Jekyll include liquid tag
Expand Down
39 changes: 19 additions & 20 deletions example/_includes/post.html
Expand Up @@ -12,26 +12,25 @@ <h1 id="title">{{ page.title }}</h1>
</div>

<div class="post">
{% if site.lang == "it" %}
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
{% capture link3 %}{{ site.baseurl_root }}/es{{ page.url}}{% endcapture %}
<div align="right">
<a href="{{ link1 }}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{{ link3 }}" >{% t global.spanish %}</a>
</div>
{% elsif site.lang == "en" %}
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
{% capture link3 %}{{ site.baseurl_root }}/es{{ page.url}}{% endcapture %}
<div align="right">
<a href="{{ link3 }}" >{% t global.spanish %}</a><span class="separator"> &bull; </span><a href="{{ link2 }}" >{% t global.italian %}</a>
</div>
{% elsif site.lang == "es" %}
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
<div align="right">
<a href="{{ link1 }}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{{ link2 }}" >{% t global.italian %}</a>
</div>

{% endif %}
<div align="right">
<!-- Adds links to other languages on the post -->
{% for lang in site.languages %}
{% unless site.lang == lang %}
{% if lang == site.default_lang %}
<a href="{{ site.baseurl_root }}{{ page.url }}" >{% t langs.{{ lang }} %}</a>
{% else %}
<a href="{{ site.baseurl_root }}/{{ lang }}{{ page.url }}" >{% t langs.{{ lang }} %}</a>
{% endif %}

{% assign next = forloop.index | plus: 1 %}

{% if forloop.last != true and site.languages[forloop.index] != site.lang or site.languages[forloop.index] == site.lang and next < forloop.length %}
<span class="separator"> &bull; </span>
{% endif %}

{% endunless %}
{% endfor %}
</div>

<p>{% t pages.includeexample %}: <b>{{ include.param }}</b></p>

Expand Down
38 changes: 19 additions & 19 deletions example/pagination/index.html
Expand Up @@ -20,25 +20,25 @@ <h1 id="title">{{ title }}</h1>
</div>

<div class="post">
{% if site.lang == "it" %}
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
{% capture link3 %}{{ site.baseurl_root }}/es{{ page.url}}{% endcapture %}
<div align="right">
<a href="{{ link1 }}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{{ link3 }}" >{% t global.spanish %}</a>
</div>
{% elsif site.lang == "en" %}
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
{% capture link3 %}{{ site.baseurl_root }}/es{{ page.url }}{% endcapture %}
<div align="right">
<a href="{{ link3 }}" >{% t global.spanish %}</a><span class="separator"> &bull; </span><a href="{{ link2 }}" >{% t global.italian %}</a>
</div>
{% elsif site.lang == "es" %}
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url }}{% endcapture %}
<div align="right">
<a href="{{ link1 }}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{{ link2 }}" >{% t global.italian %}</a>
</div>
{% endif %}
<div align="right">
<!-- Adds links to other languages on the post -->
{% for lang in site.languages %}
{% unless site.lang == lang %}
{% if lang == site.default_lang %}
<a href="{{ site.baseurl_root }}{{ page.url }}" >{% t langs.{{ lang }} %}</a>
{% else %}
<a href="{{ site.baseurl_root }}/{{ lang }}{{ page.url }}" >{% t langs.{{ lang }} %}</a>
{% endif %}
{% assign next = forloop.index | plus: 1 %}
{% if forloop.last != true and site.languages[forloop.index] != site.lang or site.languages[forloop.index] == site.lang and next < forloop.length %}
<span class="separator"> &bull; </span>
{% endif %}
{% endunless %}
{% endfor %}
</div>

<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
Expand Down
38 changes: 16 additions & 22 deletions example/permalink.html
Expand Up @@ -25,28 +25,22 @@ <h1 id="title">{{ page.title }}</h1>
</div>

<div class="post">
{% if site.lang == "it" %}
{% capture link_en %}{{page.namespace}} en{% endcapture %}
{% capture link_es %}{{page.namespace}} es{% endcapture %}
<div align="right">
<a href="{% tl {{ link_en }} %}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{% tl {{ link_es }} %}" >{% t global.spanish %}</a>
</div>
{% elsif site.lang == "en" %}
{% capture link_it %}{{page.namespace}} it{% endcapture %}
{% capture link_es %}{{page.namespace}} es{% endcapture %}
<div align="right">
<a href="{% tl {{ link_it }} %}" >{% t global.italian %}</a><span class="separator"> &bull; </span><a href="{% tl {{ link_es }} %}" >{% t global.spanish %}</a>
</div>
{% elsif site.lang == "es" %}
{% capture link_en %}{{page.namespace}} en{% endcapture %}
{% capture link_it %}{{page.namespace}} it{% endcapture %}
<div align="right">
<a href="{% tl {{ link_en }} %}" >{% t global.english %}</a><span class="separator"> &bull; </span><a href="{% tl {{ link_it }} %}" >{% t global.italian %}</a>
</div>
{% endif %}



<div align="right">
<!-- Adds links to other languages on the post -->
{% for lang in site.languages %}
{% unless site.lang == lang %}
<a href="{% tl {{ page.namespace }} {{ lang }} %}" >{% t langs.{{ lang }} %}</a>

{% assign next = forloop.index | plus: 1 %}

{% if forloop.last != true and site.languages[forloop.index] != site.lang or site.languages[forloop.index] == site.lang and next < forloop.length %}
<span class="separator"> &bull; </span>
{% endif %}

{% endunless %}
{% endfor %}
</div>

{% tf permalink.md %}
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions lib/jekyll-multiple-languages-plugin.rb
Expand Up @@ -270,6 +270,8 @@ def render(context)
key = @key
end

key = Liquid::Template.parse(key).render(context) # Parses and renders some Liquid syntax on arguments (allows expansions)

site = context.registers[:site] # Jekyll site object

lang = site.config['lang']
Expand Down Expand Up @@ -313,6 +315,8 @@ def render(context)
file = @file
end

file = Liquid::Template.parse(file).render(context) # Parses and renders some Liquid syntax on arguments (allows expansions)

site = context.registers[:site] # Jekyll site object

includes_dir = File.join(site.source, '_i18n/' + site.config['lang'])
Expand Down Expand Up @@ -375,6 +379,8 @@ def render(context)
key = @key
end

key = Liquid::Template.parse(key).render(context) # Parses and renders some Liquid syntax on arguments (allows expansions)

site = context.registers[:site] # Jekyll site object

key = key.split
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin/version.rb
@@ -1,6 +1,6 @@
module Jekyll
module MultipleLanguagesPlugin
VERSION = "1.4.2"
VERSION = "1.5.0"
end
end

0 comments on commit 532c713

Please sign in to comment.