jekyll-language-plugin 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +0 -2
- data/README.md +6 -6
- data/lib/jekyll-language-plugin/liquid_context.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b6c261bef7ca88520afb58ec4a1760617681229
|
4
|
+
data.tar.gz: fd4978a18ea984aacdccafb8b43b6c8b20cb6323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1528ab446fa8b5446dfa068aa377f669d8933aa4fae6faab3f021fc9c502d1a9b53134398a6fa15e8490a150a3b8f2f1d101da30ad0c119427d20f4900e75986
|
7
|
+
data.tar.gz: 1782d0f93101c1a2dfceaf5783eaf859138f201153dceb0e8f486c2242e246b66106bc0b5bab28969b1c1bb90c7a2c585ecd6d981a337ab921a0d9b8ecba24ec
|
data/LICENSE.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2014 GitHub, inc.
|
4
|
-
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
4
|
of this software and associated documentation files (the "Software"), to deal
|
7
5
|
in the Software without restriction, including without limitation the rights
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ The first key, `language_data`, tells the plugin where it can find the translati
|
|
53
53
|
|
54
54
|
## Usage
|
55
55
|
|
56
|
-
Every page or post, that needs to be translated must either have a `language` key or a `languages` array inside its YAML front-matter. Additionally, it may also have an `
|
56
|
+
Every page or post, that needs to be translated must either have a `language` key or a `languages` array inside its YAML front-matter. Additionally, it may also have an `subset` key which tells the plugin to traverse one step further into the language data. So for example, if `subset` is `home` and the `language_data` configuration setting is `data.lang.%%` and the language is `en`, the plugin will look into `data.lang.en.home` for the translation keys used by the liquid tag. Of course, only pages and layouts can use the translation liquid tag but layouts used by posts can therefore benefit from an `subset`.
|
57
57
|
|
58
58
|
### Example
|
59
59
|
|
@@ -62,7 +62,7 @@ This is a page optimized for the language plugin, `home.html`:
|
|
62
62
|
```
|
63
63
|
---
|
64
64
|
layout: default
|
65
|
-
|
65
|
+
subset: home
|
66
66
|
languages:
|
67
67
|
- en
|
68
68
|
- de
|
@@ -107,7 +107,7 @@ Create a new file `_layouts/default.html` which will contain the default layout:
|
|
107
107
|
</html>
|
108
108
|
```
|
109
109
|
|
110
|
-
As a
|
110
|
+
As a side note, if a `subset` is given and the translation liquid tag can not find a key within the given subset of the specified language, it will perform another lookup without the given subset.
|
111
111
|
|
112
112
|
So if `footnote` is common to all pages and posts, it can be placed within the root of each language file. For the English language, add the following to `_data/lang/en.yml`:
|
113
113
|
|
@@ -125,7 +125,7 @@ If you now run `jekyll build`, you will obtain two separate `home.html` files in
|
|
125
125
|
|
126
126
|
### Posts
|
127
127
|
|
128
|
-
Similar to pages, posts can also have the `languages` or `language` keys
|
128
|
+
Similar to pages, posts can also have the `languages` or `language` keys as well as the `subset` key in its YAML front-matter. You can use all supported liquid tags and filters to translate posts but you can also create multiple posts, one for each language.
|
129
129
|
|
130
130
|
## Liquid tags
|
131
131
|
|
@@ -135,9 +135,9 @@ Currently, there are two liquid tags provided by this plugin.
|
|
135
135
|
|
136
136
|
The `t` liquid tag provides a convenient way of accessing language-specific translations from the language data referred to in the configuration file.
|
137
137
|
|
138
|
-
If
|
138
|
+
If a `subset` is given by the page's or post's front-matter, `t` will look into the given `subset` of the language specified. Only if the key cannot be found there, it will perform another lookup without traversing into the given subset. This can be useful for common translations like a copyright notice. The key can also be a dot-notation of cascaded keys which are traversed upon lookup.
|
139
139
|
|
140
|
-
*Example*: `{% t homepage_welcome %}`
|
140
|
+
*Example*: `{% t homepage_welcome %}` or `{% t homepage.welcome %}`
|
141
141
|
|
142
142
|
### Language-Specific Include Tag
|
143
143
|
|
@@ -23,9 +23,9 @@ module JekyllLanguagePlugin
|
|
23
23
|
data = self.get_language_data(context)
|
24
24
|
return "" if data.nil?
|
25
25
|
|
26
|
-
|
27
|
-
if (!
|
28
|
-
!(str = traverse_hash(traverse_hash(data,
|
26
|
+
language_subset = context.registers[:page]['subset']
|
27
|
+
if (!language_subset.to_s.empty? &&
|
28
|
+
!(str = traverse_hash(traverse_hash(data, language_subset), key)).to_s.empty?) ||
|
29
29
|
!(str = traverse_hash(data, key)).to_s.empty?
|
30
30
|
return str
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-language-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Wochnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|