jekyll-multiple-languages-plugin 1.2.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: 7b82f848f59fd42778adc49bc185a780936778b0
4
+ data.tar.gz: 7bc74540378b2818dd3540726e9bbf149fc7f7ea
5
+ SHA512:
6
+ metadata.gz: 2e6d1ebea84906ebbc8c92dd89fb414286a224a85bfab497826fc672650d09c63ac8affa47b72a20eaa9e8d00806e3d59175141df9ec8fd712cc96f8a6eed7b6
7
+ data.tar.gz: 5bebf75a7bf024197f0524b24ced3460a5d76087af8dd3c578c336fcf7007c2c28d19dd8afe5d6f6dfc28b561d688a8fd21ce0f0c1c7affc35810fe4108d52ca
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ example/Gemfile.lock
20
+ example/_site
21
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-multiple-languages-plugin.gemspec
4
+ gemspec
@@ -0,0 +1,180 @@
1
+ Mozilla Public License
2
+ Version 2.0
3
+
4
+ 1. Definitions
5
+
6
+ 1.1. “Contributor”
7
+ means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
8
+
9
+ 1.2. “Contributor Version”
10
+ means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
11
+
12
+ 1.3. “Contribution”
13
+ means Covered Software of a particular Contributor.
14
+
15
+ 1.4. “Covered Software”
16
+ means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
17
+
18
+ 1.5. “Incompatible With Secondary Licenses”
19
+ means
20
+
21
+ that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
22
+
23
+ that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
24
+
25
+ 1.6. “Executable Form”
26
+ means any form of the work other than Source Code Form.
27
+
28
+ 1.7. “Larger Work”
29
+ means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
30
+
31
+ 1.8. “License”
32
+ means this document.
33
+
34
+ 1.9. “Licensable”
35
+ means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
36
+
37
+ 1.10. “Modifications”
38
+ means any of the following:
39
+
40
+ any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
41
+
42
+ any new file in Source Code Form that contains any Covered Software.
43
+
44
+ 1.11. “Patent Claims” of a Contributor
45
+ means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
46
+
47
+ 1.12. “Secondary License”
48
+ means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
49
+
50
+ 1.13. “Source Code Form”
51
+ means the form of the work preferred for making modifications.
52
+
53
+ 1.14. “You” (or “Your”)
54
+ means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
55
+
56
+ 2. License Grants and Conditions
57
+
58
+ 2.1. Grants
59
+
60
+ Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
61
+
62
+ under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
63
+
64
+ under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
65
+
66
+ 2.2. Effective Date
67
+
68
+ The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
69
+
70
+ 2.3. Limitations on Grant Scope
71
+
72
+ The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
73
+
74
+ for any code that a Contributor has removed from Covered Software; or
75
+
76
+ for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
77
+
78
+ under Patent Claims infringed by Covered Software in the absence of its Contributions.
79
+
80
+ This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
81
+
82
+ 2.4. Subsequent Licenses
83
+
84
+ No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
85
+
86
+ 2.5. Representation
87
+
88
+ Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
89
+
90
+ 2.6. Fair Use
91
+
92
+ This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
93
+
94
+ 2.7. Conditions
95
+
96
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
97
+
98
+ 3. Responsibilities
99
+
100
+ 3.1. Distribution of Source Form
101
+
102
+ All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
103
+
104
+ 3.2. Distribution of Executable Form
105
+
106
+ If You distribute Covered Software in Executable Form then:
107
+
108
+ such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
109
+
110
+ You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
111
+
112
+ 3.3. Distribution of a Larger Work
113
+
114
+ You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
115
+
116
+ 3.4. Notices
117
+
118
+ You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
119
+
120
+ 3.5. Application of Additional Terms
121
+
122
+ You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
123
+
124
+ 4. Inability to Comply Due to Statute or Regulation
125
+
126
+ If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
127
+
128
+ 5. Termination
129
+
130
+ 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
131
+
132
+ 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
133
+
134
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
135
+
136
+ 6. Disclaimer of Warranty
137
+
138
+ Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
139
+
140
+ 7. Limitation of Liability
141
+
142
+ Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
143
+
144
+ 8. Litigation
145
+
146
+ Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
147
+
148
+ 9. Miscellaneous
149
+
150
+ This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
151
+
152
+ 10. Versions of the License
153
+
154
+ 10.1. New Versions
155
+
156
+ Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
157
+
158
+ 10.2. Effect of New Versions
159
+
160
+ You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
161
+
162
+ 10.3. Modified Versions
163
+
164
+ If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
165
+
166
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
167
+
168
+ If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
169
+
170
+ Exhibit A - Source Code Form License Notice
171
+
172
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
173
+
174
+ If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
175
+
176
+ You may add additional accurate notices of copyright ownership.
177
+
178
+ Exhibit B - “Incompatible With Secondary Licenses” Notice
179
+
180
+ This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
@@ -0,0 +1,195 @@
1
+ # Multiple Languages in Jekyll
2
+
3
+ Jekyll Multiple Languages is an internationalization plugin for [Jekyll](https://github.com/mojombo/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 sub folders with the same name as the language it contains.
4
+
5
+ The plugin is developed as an utility at [Screen Interaction](http://www.screeninteraction.com)
6
+
7
+ ##Installation
8
+ ### Submodule
9
+ If your Jekyll project is in a git repository, you can easily
10
+ manage your plugins by utilizing git submodules.
11
+
12
+ To install this plugin as a git submodule:
13
+
14
+ git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages
15
+
16
+ To update:
17
+
18
+ cd _plugins/multiple-languages
19
+ git pull origin master
20
+
21
+
22
+ ### Copy file
23
+ Copy or link the file `lib/jekyll/multiple/languages/plugin.rb` into your `_plugins` folder for your Jekyll project.
24
+
25
+
26
+ ### Gem [![Gem Version](https://badge.fury.io/rb/jekyll-multiple-languages-plugin.png)](http://badge.fury.io/rb/jekyll-multiple-languages-plugin)
27
+
28
+ This plugin is available as a Rubygem, https://rubygems.org/gems/jekyll-multiple-languages-plugin.
29
+
30
+ Add this line to your application's Gemfile:
31
+
32
+ gem 'jekyll-multiple-languages-plugin'
33
+
34
+ And then execute:
35
+
36
+ $ bundle
37
+
38
+ Or install it yourself as:
39
+
40
+ $ gem install jekyll-multiple-languages-plugin
41
+
42
+ To activate the plugin add this line in to a *.rb file in the _plugins directory:
43
+
44
+ require 'jekyll/multiple/languages/plugin'
45
+
46
+
47
+ ###Features
48
+ * Supports multiple languages with the same code base.
49
+ * Supports all template languages that your Liquid pipeline supports.
50
+ * Uses [Liquid tags](https://github.com/Shopify/liquid) in your HTML for including translated strings.
51
+ * Compiles the site multiple times for all supported languages into separate subfolders.
52
+ * The plugin even works with the -watch flag turned on and will rebuild all languages automatically.
53
+ * Contains an example web site thanks to [@davrandom](https://github.com/davrandom/)
54
+ * Supports translated keys in YAML format
55
+ * Supports translated template files
56
+ * _NEW!_ Supports writing translated posts
57
+
58
+ ##Usage
59
+ ###Configuration
60
+ Add the i18n configuration to your _config.yml:
61
+
62
+ ```yaml
63
+ languages: ["sv", "en", "de", "fr"]
64
+ ```
65
+
66
+ The first language in the array will be the default language, English, German and French will be added in to separate subfolders.
67
+
68
+ ###i18n
69
+ Create this folder structure in your Jekyll project as an example:
70
+
71
+ - /_i18n/sv.yml
72
+ - /_i18n/en.yml
73
+ - /_i18n/de.yml
74
+ - /_i18n/fr.yml
75
+ - /_i18n/sv/pagename/blockname.md
76
+ - /_i18n/en/pagename/blockname.md
77
+ - /_i18n/de/pagename/blockname.md
78
+ - /_i18n/fr/pagename/blockname.md
79
+
80
+ To add a string to your site use one of these
81
+
82
+ ```liquid
83
+ {% t key %}
84
+ or
85
+ {% translate key %}
86
+ ```
87
+
88
+ Liquid tags. This will pick the correct string from the `language.yml` file during compilation.
89
+
90
+ The language.yml files are written in YAML syntax which caters for a simple grouping of strings.
91
+
92
+ ```yaml
93
+ global:
94
+ swedish: Svenska
95
+ english: English
96
+ pages:
97
+ home: Home
98
+ work: Work
99
+ ```
100
+
101
+ To access the english key, use this tag:
102
+
103
+ ```liquid
104
+ {% t global.english %}
105
+ or
106
+ {% translate global.english %}
107
+ ```
108
+
109
+ The plugin also supports using different markdown files for different languages using the
110
+
111
+ ```liquid
112
+ {% tf pagename/blockname.md %}
113
+ or
114
+ {% translate_file pagename/blockname.md %}
115
+ ```
116
+
117
+ This plugin have exactly the same support and syntax as the built in
118
+
119
+ ```liquid
120
+ {% include file %}
121
+ ```
122
+
123
+ tag, so plugins that extends its functionality should be picked up by this plugin as well.
124
+
125
+ ###i18n in templates
126
+ 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 different string in different pages even if they use the same template.
127
+
128
+ A perfect example is this:
129
+
130
+ ```html
131
+ <html>
132
+ <head>
133
+ <title>{% t page.title %}</title>
134
+ </head>
135
+ </html>
136
+ ```
137
+
138
+ So how can I add different translated titles to all pages? Don't worry, it's easy. The Multiple Languages plugin supports Liguid variables as well as strings so define a page variable in your page definition
139
+
140
+ ```yaml
141
+ ---
142
+ layout: default
143
+ title: titles.home
144
+ ---
145
+ ```
146
+
147
+ and `<title>{% t page.title %}</title>` will pick up the `titles.home` key from `language.yml`
148
+
149
+ ```yaml
150
+ titles:
151
+ home: "Home"
152
+ ```
153
+
154
+ ##Link between languages
155
+ This plugin gives you the variables
156
+
157
+ ```liquid
158
+ {{ page.lang }}
159
+
160
+ and
161
+
162
+ {{ site.baseurl_root }}
163
+ ```
164
+
165
+ to play with in your template files.
166
+
167
+ This allows you to create solutions like this:
168
+
169
+
170
+ ``` liquid
171
+ {% if site.lang == "sv" %}
172
+ {% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
173
+ <a href="{{ link1 }}" >{% t global.english %}</a>
174
+ {% else if site.lang == "en" %}
175
+ {% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
176
+ <a href="{{ link2 }}" >{% t global.swedish %}</a>
177
+ {% endif %}
178
+ ```
179
+
180
+ This snippet will create a link that will toggle between Swedish and English. A more detailed description of the variables used follows:
181
+
182
+ | Name | Value | Example |
183
+ | ---: | :--- | :--- |
184
+ | site.lang | The language used in the current compilation stage | ``` en ``` |
185
+ | site.baseurl | Points to the root of the site including the current language | ``` http://foo.bar/en ``` |
186
+ | site.baseurl_root | Points to the root of the page without the language path | ``` http://foo.bar ``` |
187
+ | page.url | The current page's relative URL to the baseurl | ``` /a/sub/folder/page/ ```|
188
+
189
+ ## Contributing
190
+
191
+ 1. Fork it
192
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
193
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
194
+ 4. Push to the branch (`git push origin my-new-feature`)
195
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gem 'github-pages'
3
+ #gem 'multiple-languages-plugin'
4
+ gem "jekyll"
5
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jeff Martin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ Minimal website using multiple languages plugin
2
+ ====
3
+
4
+ Features:
5
+ - internationalization of the website
6
+ - per-post translation link
7
+
8
+ Notes:
9
+ - The website is based on Flex theme.
10
+ - It does not work with github pages because the I18N plugin is not in the main jekyll repo and is not considered "safe".
11
+