jekyll-i18n_tags 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fe4bb8dd0032bdc3e446c672537fcc9a5cc38a66
4
+ data.tar.gz: 00e45c24e6cab1985ed710a9b0b77a8fc12b4df1
5
+ SHA512:
6
+ metadata.gz: a3eb17b421373e228a25c1b7583aa23c69c9e5739b36bf9dd0a354db417cd5e32fade31c9df68876adb471c65f20ffbc9479879c53fb22f8452212d45e24d8e1
7
+ data.tar.gz: abc0b9d0c4549653363198136ea5b0aed5ec5dc9b05270399205c161cff8360c17102169f2c553230b4b24e32c363adb3c02411921bc948e55973f57b6a99dd0
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright © 2016 Krzysztof Jurewicz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # jekyll-i18n_tags
2
+
3
+ This [Jekyll](https://jekyllrb.com) plugin provides a simple tag for translating templates.
4
+
5
+ ## Installation
6
+
7
+ Add the `jekyll-i18n_tags` gem to the `:jekyll_plugins` group in your `Gemfile`:
8
+
9
+ ```ruby
10
+ group :jekyll_plugins do
11
+ gem 'jekyll-i18n_tags', '~>1'
12
+ end
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Put the configuration and translations in your `_config.yml`:
18
+
19
+ ```yaml
20
+ # Source language is optional. If set, translations to it will not be
21
+ # performed.
22
+ source_lang: en
23
+ translations:
24
+ pl:
25
+ Hello, world!: Witaj, świecie!
26
+ ```
27
+
28
+ In your templates, use the `t` tag:
29
+
30
+ ```liquid
31
+ {% t Hello, world! %}
32
+ ```
33
+
34
+ For each page which uses the translation tag, you need to set `lang` variable (you may want to use [front matter defaults](http://jekyllrb.com/docs/configuration/#front-matter-defaults) to faciliate this).
35
+
36
+ ## Versioning
37
+
38
+ This project uses [semantic versioning](http://semver.org/).
39
+
40
+ ## License
41
+
42
+ This software is licensed under [the MIT License](LICENSE).
@@ -0,0 +1 @@
1
+ require 'jekyll/i18n_tags'
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Jekyll
4
+ class I18NTag < Liquid::Tag
5
+ def initialize(tag_name, text, tokens)
6
+ super
7
+ @text = text.strip
8
+ end
9
+
10
+ def render(context)
11
+ lang = context['page']['lang']
12
+ raise "Page language not specified: #{context['page']['path']}" unless lang
13
+ site = context['site']
14
+ source_lang = context['site']['source_lang']
15
+ if lang == source_lang
16
+ @text
17
+ else
18
+ translations = site['translations'][lang]
19
+ raise 'Translations not provided' unless translations
20
+ translation = translations[@text]
21
+ raise "Translation not provided: #{@text}" unless translation
22
+ translation
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ Liquid::Template.register_tag('t', Jekyll::I18NTag)
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-i18n_tags
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Jurewicz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.38'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.38.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.38'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.38.0
33
+ description: Tags for translating Jekyll templates.
34
+ email: krzysztof.jurewicz@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files:
38
+ - README.md
39
+ - LICENSE
40
+ files:
41
+ - LICENSE
42
+ - README.md
43
+ - lib/jekyll-i18n_tags.rb
44
+ - lib/jekyll/i18n_tags.rb
45
+ homepage: https://github.com/KrzysiekJ/jekyll-i18n_tags
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.4.5
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Translate your Jekyll templates.
69
+ test_files: []
70
+ has_rdoc: