jekyll-multiple-languages-plugin 1.5.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +5 -349
- data/README.md +133 -56
- data/lib/jekyll-multiple-languages-plugin.rb +242 -40
- data/lib/plugin/version.rb +1 -1
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d2f78a4cba9b1b00c236740a245bbc561cbf9740b330830a2464129ce44b818
|
4
|
+
data.tar.gz: 4efb2e419030c21a53ca1f3b38018bf31681a74e8c57fb4592ee375c6783a5e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f559010eec5ac54b67d651b8f77a06cc0004fc63a631aca402754dfc3b8b900fea14687c8b99f40c0156aef66146f70babdb9dd78d86b4ca9364268a80c629
|
7
|
+
data.tar.gz: 870ec29d2941d9f08be8c21e179703fa6ca58ec3b8c15f00ab663ab54e5b8501a02b5bea47a43a80c271e3d8450f20e839098b2971539d6c37879991c0493cb4
|
data/LICENSE.txt
CHANGED
@@ -1,353 +1,9 @@
|
|
1
|
-
|
2
|
-
==================================
|
1
|
+
MIT License
|
3
2
|
|
4
|
-
|
5
|
-
--------------
|
3
|
+
Copyright (c) 2014 Martin Kurtsson
|
6
4
|
|
7
|
-
|
8
|
-
means each individual or legal entity that creates, contributes to the
|
9
|
-
creation of, or owns Covered Software.
|
5
|
+
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:
|
10
6
|
|
11
|
-
|
12
|
-
means the combination of the Contributions of others (if any) used by a
|
13
|
-
Contributor and that particular Contributor's Contribution.
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
14
8
|
|
15
|
-
|
16
|
-
means Covered Software of a particular Contributor.
|
17
|
-
|
18
|
-
1.4. "Covered Software"
|
19
|
-
means Source Code Form to which the initial Contributor has attached the
|
20
|
-
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
21
|
-
Modifications of such Source Code Form, in each case including portions
|
22
|
-
thereof.
|
23
|
-
|
24
|
-
1.5. "Incompatible With Secondary Licenses"
|
25
|
-
means
|
26
|
-
|
27
|
-
(a) that the initial Contributor has attached the notice described in
|
28
|
-
Exhibit B to the Covered Software; or
|
29
|
-
|
30
|
-
(b) that the Covered Software was made available under the terms of version
|
31
|
-
1.1 or earlier of the License, but not also under the terms of a
|
32
|
-
Secondary License.
|
33
|
-
|
34
|
-
1.6. "Executable Form"
|
35
|
-
means any form of the work other than Source Code Form.
|
36
|
-
|
37
|
-
1.7. "Larger Work"
|
38
|
-
means a work that combines Covered Software with other material, in a
|
39
|
-
separate file or files, that is not Covered Software.
|
40
|
-
|
41
|
-
1.8. "License"
|
42
|
-
means this document.
|
43
|
-
|
44
|
-
1.9. "Licensable"
|
45
|
-
means having the right to grant, to the maximum extent possible, whether at
|
46
|
-
the time of the initial grant or subsequently, any and all of the rights
|
47
|
-
conveyed by this License.
|
48
|
-
|
49
|
-
1.10. "Modifications"
|
50
|
-
means any of the following:
|
51
|
-
|
52
|
-
(a) any file in Source Code Form that results from an addition to, deletion
|
53
|
-
from, or modification of the contents of Covered Software; or
|
54
|
-
|
55
|
-
(b) any new file in Source Code Form that contains any Covered Software.
|
56
|
-
|
57
|
-
1.11. "Patent Claims" of a Contributor
|
58
|
-
means any patent claim(s), including without limitation, method, process,
|
59
|
-
and apparatus claims, in any patent Licensable by such Contributor that
|
60
|
-
would be infringed, but for the grant of the License, by the making, using,
|
61
|
-
selling, offering for sale, having made, import, or transfer of either its
|
62
|
-
Contributions or its Contributor Version.
|
63
|
-
|
64
|
-
1.12. "Secondary License"
|
65
|
-
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
66
|
-
General Public License, Version 2.1, the GNU Affero General Public License,
|
67
|
-
Version 3.0, or any later versions of those licenses.
|
68
|
-
|
69
|
-
1.13. "Source Code Form"
|
70
|
-
means the form of the work preferred for making modifications.
|
71
|
-
|
72
|
-
1.14. "You" (or "Your")
|
73
|
-
means an individual or a legal entity exercising rights under this License.
|
74
|
-
For legal entities, "You" includes any entity that controls, is controlled
|
75
|
-
by, or is under common control with You. For purposes of this definition,
|
76
|
-
"control" means (a) the power, direct or indirect, to cause the direction or
|
77
|
-
management of such entity, whether by contract or otherwise, or (b)
|
78
|
-
ownership of more than fifty percent (50%) of the outstanding shares or
|
79
|
-
beneficial ownership of such entity.
|
80
|
-
|
81
|
-
2. License Grants and Conditions
|
82
|
-
--------------------------------
|
83
|
-
|
84
|
-
2.1. Grants
|
85
|
-
|
86
|
-
Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
|
87
|
-
license:
|
88
|
-
|
89
|
-
(a) under intellectual property rights (other than patent or trademark)
|
90
|
-
Licensable by such Contributor to use, reproduce, make available, modify,
|
91
|
-
display, perform, distribute, and otherwise exploit its Contributions,
|
92
|
-
either on an unmodified basis, with Modifications, or as part of a Larger
|
93
|
-
Work; and
|
94
|
-
|
95
|
-
(b) under Patent Claims of such Contributor to make, use, sell, offer for sale,
|
96
|
-
have made, import, and otherwise transfer either its Contributions or its
|
97
|
-
Contributor Version.
|
98
|
-
|
99
|
-
2.2. Effective Date
|
100
|
-
|
101
|
-
The licenses granted in Section 2.1 with respect to any Contribution become
|
102
|
-
effective for each Contribution on the date the Contributor first distributes
|
103
|
-
such Contribution.
|
104
|
-
|
105
|
-
2.3. Limitations on Grant Scope
|
106
|
-
|
107
|
-
The licenses granted in this Section 2 are the only rights granted under this
|
108
|
-
License. No additional rights or licenses will be implied from the distribution
|
109
|
-
or licensing of Covered Software under this License. Notwithstanding Section
|
110
|
-
2.1(b) above, no patent license is granted by a Contributor:
|
111
|
-
|
112
|
-
(a) for any code that a Contributor has removed from Covered Software;
|
113
|
-
or
|
114
|
-
|
115
|
-
(b) for infringements caused by: (i) Your and any other third party's
|
116
|
-
modifications of Covered Software, or (ii) the combination of its
|
117
|
-
Contributions with other software (except as part of its Contributor
|
118
|
-
Version); or
|
119
|
-
|
120
|
-
(c) under Patent Claims infringed by Covered Software in the absence of its
|
121
|
-
Contributions.
|
122
|
-
|
123
|
-
This License does not grant any rights in the trademarks, service marks, or
|
124
|
-
logos of any Contributor (except as may be necessary to comply with the notice
|
125
|
-
requirements in Section 3.4).
|
126
|
-
|
127
|
-
2.4. Subsequent Licenses
|
128
|
-
|
129
|
-
No Contributor makes additional grants as a result of Your choice to distribute
|
130
|
-
the Covered Software under a subsequent version of this License (see Section
|
131
|
-
10.2) or under the terms of a Secondary License (if permitted under the terms of
|
132
|
-
Section 3.3).
|
133
|
-
|
134
|
-
2.5. Representation
|
135
|
-
|
136
|
-
Each Contributor represents that the Contributor believes its Contributions are
|
137
|
-
its original creation(s) or it has sufficient rights to grant the rights to its
|
138
|
-
Contributions conveyed by this License.
|
139
|
-
|
140
|
-
2.6. Fair Use
|
141
|
-
|
142
|
-
This License is not intended to limit any rights You have under applicable
|
143
|
-
copyright doctrines of fair use, fair dealing, or other equivalents.
|
144
|
-
|
145
|
-
2.7. Conditions
|
146
|
-
|
147
|
-
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
148
|
-
Section 2.1.
|
149
|
-
|
150
|
-
3. Responsibilities
|
151
|
-
-------------------
|
152
|
-
|
153
|
-
3.1. Distribution of Source Form
|
154
|
-
|
155
|
-
All distribution of Covered Software in Source Code Form, including any
|
156
|
-
Modifications that You create or to which You contribute, must be under the
|
157
|
-
terms of this License. You must inform recipients that the Source Code Form of
|
158
|
-
the Covered Software is governed by the terms of this License, and how they can
|
159
|
-
obtain a copy of this License. You may not attempt to alter or restrict the
|
160
|
-
recipients' rights in the Source Code Form.
|
161
|
-
|
162
|
-
3.2. Distribution of Executable Form
|
163
|
-
|
164
|
-
If You distribute Covered Software in Executable Form then:
|
165
|
-
|
166
|
-
(a) such Covered Software must also be made available in Source Code Form, as
|
167
|
-
described in Section 3.1, and You must inform recipients of the Executable
|
168
|
-
Form how they can obtain a copy of such Source Code Form by reasonable means
|
169
|
-
in a timely manner, at a charge no more than the cost of distribution to the
|
170
|
-
recipient; and
|
171
|
-
|
172
|
-
(b) You may distribute such Executable Form under the terms of this License, or
|
173
|
-
sublicense it under different terms, provided that the license for the
|
174
|
-
Executable Form does not attempt to limit or alter the recipients' rights in
|
175
|
-
the Source Code Form under this License.
|
176
|
-
|
177
|
-
3.3. Distribution of a Larger Work
|
178
|
-
|
179
|
-
You may create and distribute a Larger Work under terms of Your choice, provided
|
180
|
-
that You also comply with the requirements of this License for the Covered
|
181
|
-
Software. If the Larger Work is a combination of Covered Software with a work
|
182
|
-
governed by one or more Secondary Licenses, and the Covered Software is not
|
183
|
-
Incompatible With Secondary Licenses, this License permits You to additionally
|
184
|
-
distribute such Covered Software under the terms of such Secondary License(s),
|
185
|
-
so that the recipient of the Larger Work may, at their option, further
|
186
|
-
distribute the Covered Software under the terms of either this License or such
|
187
|
-
Secondary License(s).
|
188
|
-
|
189
|
-
3.4. Notices
|
190
|
-
|
191
|
-
You may not remove or alter the substance of any license notices (including
|
192
|
-
copyright notices, patent notices, disclaimers of warranty, or limitations of
|
193
|
-
liability) contained within the Source Code Form of the Covered Software, except
|
194
|
-
that You may alter any license notices to the extent required to remedy known
|
195
|
-
factual inaccuracies.
|
196
|
-
|
197
|
-
3.5. Application of Additional Terms
|
198
|
-
|
199
|
-
You may choose to offer, and to charge a fee for, warranty, support, indemnity
|
200
|
-
or liability obligations to one or more recipients of Covered Software. However,
|
201
|
-
You may do so only on Your own behalf, and not on behalf of any Contributor. You
|
202
|
-
must make it absolutely clear that any such warranty, support, indemnity, or
|
203
|
-
liability obligation is offered by You alone, and You hereby agree to indemnify
|
204
|
-
every Contributor for any liability incurred by such Contributor as a result of
|
205
|
-
warranty, support, indemnity or liability terms You offer. You may include
|
206
|
-
additional disclaimers of warranty and limitations of liability specific to any
|
207
|
-
jurisdiction.
|
208
|
-
|
209
|
-
4. Inability to Comply Due to Statute or Regulation
|
210
|
-
---------------------------------------------------
|
211
|
-
|
212
|
-
If it is impossible for You to comply with any of the terms of this License with
|
213
|
-
respect to some or all of the Covered Software due to statute, judicial order,
|
214
|
-
or regulation then You must: (a) comply with the terms of this License to the
|
215
|
-
maximum extent possible; and (b) describe the limitations and the code they
|
216
|
-
affect. Such description must be placed in a text file included with all
|
217
|
-
distributions of the Covered Software under this License. Except to the extent
|
218
|
-
prohibited by statute or regulation, such description must be sufficiently
|
219
|
-
detailed for a recipient of ordinary skill to be able to understand it.
|
220
|
-
|
221
|
-
5. Termination
|
222
|
-
--------------
|
223
|
-
|
224
|
-
5.1. The rights granted under this License will terminate automatically if You
|
225
|
-
fail to comply with any of its terms. However, if You become compliant, then the
|
226
|
-
rights granted under this License from a particular Contributor are reinstated
|
227
|
-
(a) provisionally, unless and until such Contributor explicitly and finally
|
228
|
-
terminates Your grants, and (b) on an ongoing basis, if such Contributor fails
|
229
|
-
to notify You of the non-compliance by some reasonable means prior to 60 days
|
230
|
-
after You have come back into compliance. Moreover, Your grants from a
|
231
|
-
particular Contributor are reinstated on an ongoing basis if such Contributor
|
232
|
-
notifies You of the non-compliance by some reasonable means, this is the first
|
233
|
-
time You have received notice of non-compliance with this License from such
|
234
|
-
Contributor, and You become compliant prior to 30 days after Your receipt of the
|
235
|
-
notice.
|
236
|
-
|
237
|
-
5.2. If You initiate litigation against any entity by asserting a patent
|
238
|
-
infringement claim (excluding declaratory judgment actions, counter-claims, and
|
239
|
-
cross-claims) alleging that a Contributor Version directly or indirectly
|
240
|
-
infringes any patent, then the rights granted to You by any and all Contributors
|
241
|
-
for the Covered Software under Section 2.1 of this License shall terminate.
|
242
|
-
|
243
|
-
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
244
|
-
license agreements (excluding distributors and resellers) which have been
|
245
|
-
validly granted by You or Your distributors under this License prior to
|
246
|
-
termination shall survive termination.
|
247
|
-
|
248
|
-
********************************************************************************
|
249
|
-
* *
|
250
|
-
* 6. Disclaimer of Warranty *
|
251
|
-
* ------------------------- *
|
252
|
-
* *
|
253
|
-
* Covered Software is provided under this License on an "as is" basis, *
|
254
|
-
* without warranty of any kind, either expressed, implied, or statutory, *
|
255
|
-
* including, without limitation, warranties that the Covered Software is *
|
256
|
-
* free of defects, merchantable, fit for a particular purpose or *
|
257
|
-
* non-infringing. The entire risk as to the quality and performance of the *
|
258
|
-
* Covered Software is with You. Should any Covered Software prove defective *
|
259
|
-
* in any respect, You (not any Contributor) assume the cost of any necessary *
|
260
|
-
* servicing, repair, or correction. This disclaimer of warranty constitutes *
|
261
|
-
* an essential part of this License. No use of any Covered Software is *
|
262
|
-
* authorized under this License except under this disclaimer. *
|
263
|
-
* *
|
264
|
-
********************************************************************************
|
265
|
-
|
266
|
-
********************************************************************************
|
267
|
-
* *
|
268
|
-
* 7. Limitation of Liability *
|
269
|
-
* -------------------------- *
|
270
|
-
* *
|
271
|
-
* Under no circumstances and under no legal theory, whether tort (including *
|
272
|
-
* negligence), contract, or otherwise, shall any Contributor, or anyone who *
|
273
|
-
* distributes Covered Software as permitted above, be liable to You for any *
|
274
|
-
* direct, indirect, special, incidental, or consequential damages of any *
|
275
|
-
* character including, without limitation, damages for lost profits, loss of *
|
276
|
-
* goodwill, work stoppage, computer failure or malfunction, or any and all *
|
277
|
-
* other commercial damages or losses, even if such party shall have been *
|
278
|
-
* informed of the possibility of such damages. This limitation of liability *
|
279
|
-
* shall not apply to liability for death or personal injury resulting from *
|
280
|
-
* such party's negligence to the extent applicable law prohibits such *
|
281
|
-
* limitation. Some jurisdictions do not allow the exclusion or limitation of *
|
282
|
-
* incidental or consequential damages, so this exclusion and limitation may *
|
283
|
-
* not apply to You. *
|
284
|
-
* *
|
285
|
-
********************************************************************************
|
286
|
-
|
287
|
-
8. Litigation
|
288
|
-
-------------
|
289
|
-
|
290
|
-
Any litigation relating to this License may be brought only in the courts of a
|
291
|
-
jurisdiction where the defendant maintains its principal place of business and
|
292
|
-
such litigation shall be governed by laws of that jurisdiction, without
|
293
|
-
reference to its conflict-of-law provisions. Nothing in this Section shall
|
294
|
-
prevent a party's ability to bring cross-claims or counter-claims.
|
295
|
-
|
296
|
-
9. Miscellaneous
|
297
|
-
----------------
|
298
|
-
|
299
|
-
This License represents the complete agreement concerning the subject matter
|
300
|
-
hereof. If any provision of this License is held to be unenforceable, such
|
301
|
-
provision shall be reformed only to the extent necessary to make it enforceable.
|
302
|
-
Any law or regulation which provides that the language of a contract shall be
|
303
|
-
construed against the drafter shall not be used to construe this License against
|
304
|
-
a Contributor.
|
305
|
-
|
306
|
-
10. Versions of the License
|
307
|
-
---------------------------
|
308
|
-
|
309
|
-
10.1. New Versions
|
310
|
-
|
311
|
-
Mozilla Foundation is the license steward. Except as provided in Section 10.3,
|
312
|
-
no one other than the license steward has the right to modify or publish new
|
313
|
-
versions of this License. Each version will be given a distinguishing version
|
314
|
-
number.
|
315
|
-
|
316
|
-
10.2. Effect of New Versions
|
317
|
-
|
318
|
-
You may distribute the Covered Software under the terms of the version of the
|
319
|
-
License under which You originally received the Covered Software, or under the
|
320
|
-
terms of any subsequent version published by the license steward.
|
321
|
-
|
322
|
-
10.3. Modified Versions
|
323
|
-
|
324
|
-
If you create software not governed by this License, and you want to create a
|
325
|
-
new license for such software, you may create and use a modified version of this
|
326
|
-
License if you rename the license and remove any references to the name of the
|
327
|
-
license steward (except to note that such modified license differs from this
|
328
|
-
License).
|
329
|
-
|
330
|
-
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
331
|
-
|
332
|
-
If You choose to distribute Source Code Form that is Incompatible With Secondary
|
333
|
-
Licenses under the terms of this version of the License, the notice described in
|
334
|
-
Exhibit B of this License must be attached.
|
335
|
-
|
336
|
-
Exhibit A - Source Code Form License Notice
|
337
|
-
-------------------------------------------
|
338
|
-
|
339
|
-
This Source Code Form is subject to the terms of the Mozilla Public License,
|
340
|
-
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
341
|
-
obtain one at http://mozilla.org/MPL/2.0/.
|
342
|
-
|
343
|
-
If it is not possible or desirable to put the notice in a particular file, then
|
344
|
-
You may include the notice in a location (such as a LICENSE file in a relevant
|
345
|
-
directory) where a recipient would be likely to look for such a notice.
|
346
|
-
|
347
|
-
You may add additional accurate notices of copyright ownership.
|
348
|
-
|
349
|
-
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
350
|
-
---------------------------------------------------------
|
351
|
-
|
352
|
-
This Source Code Form is "Incompatible With Secondary Licenses", as defined by
|
353
|
-
the Mozilla Public License, v. 2.0.
|
9
|
+
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.
|
data/README.md
CHANGED
@@ -4,48 +4,56 @@
|
|
4
4
|
|
5
5
|
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 subfolders with the same name as the language it contains.
|
6
6
|
|
7
|
-
The plugin was developed as a utility at [
|
7
|
+
The plugin was developed as a utility at [Daresay](https://daresay.co)
|
8
8
|
|
9
|
-
###
|
9
|
+
### Badges
|
10
|
+
[![Build Status](https://travis-ci.com/kurtsson/jekyll-multiple-languages-plugin.svg?branch=master)](https://travis-ci.com/kurtsson/jekyll-multiple-languages-plugin)
|
11
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-multiple-languages-plugin.png)](http://badge.fury.io/rb/jekyll-multiple-languages-plugin)
|
10
12
|
|
13
|
+
## !! We are looking for more maintainers !!
|
14
|
+
|
15
|
+
Are you using this plugin? Could you test and verify incoming PRs? Please give us a shout!
|
11
16
|
|
12
17
|
|
13
18
|
Table of Contents
|
14
19
|
-----------------
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
- [Jekyll Multiple Languages Plugin](#jekyll-multiple-languages-plugin)
|
21
|
+
- [Badges](#badges)
|
22
|
+
- [!! We are looking for more maintainers !!](#-we-are-looking-for-more-maintainers-)
|
23
|
+
- [Table of Contents](#table-of-contents)
|
24
|
+
- [1. Current Release Notice](#1-current-release-notice)
|
25
|
+
- [2. Features](#2-features)
|
26
|
+
- [3. Installation](#3-installation)
|
27
|
+
- [3.1. Using the gem](#31-using-the-gem)
|
28
|
+
- [3.2. Manually](#32-manually)
|
29
|
+
- [3.3. As a Git Submodule](#33-as-a-git-submodule)
|
30
|
+
- [4. Configuration](#4-configuration)
|
31
|
+
- [4.1. _config.yml](#41-_configyml)
|
32
|
+
- [4.2. Folder structure](#42-folder-structure)
|
33
|
+
- [5. Usage](#5-usage)
|
34
|
+
- [5.1. Translating strings](#51-translating-strings)
|
35
|
+
- [5.2. Including translated files](#52-including-translated-files)
|
36
|
+
- [5.3. Permalinks and Translating Links](#53-permalinks-and-translating-links)
|
37
|
+
- [5.4. i18n in templates](#54-i18n-in-templates)
|
38
|
+
- [5.5. Link between languages](#55-link-between-languages)
|
39
|
+
- [5.6. Creating pages](#56-creating-pages)
|
40
|
+
- [5.7. Creating posts](#57-creating-posts)
|
41
|
+
- [5.8. Select pages to translations](#58-select-pages-to-translations)
|
42
|
+
- [6. License](#6-license)
|
43
|
+
- [7. Example website](#7-example-website)
|
44
|
+
- [7.1. Adding a new language](#71-adding-a-new-language)
|
45
|
+
- [7.2. Adding new page](#72-adding-new-page)
|
46
|
+
- [8. Changelog](#8-changelog)
|
47
|
+
- [9. Contributing](#9-contributing)
|
48
|
+
- [Contributors](#contributors)
|
49
|
+
- [Created by](#created-by)
|
50
|
+
- [Maintained by](#maintained-by)
|
51
|
+
- [Former maintainer](#former-maintainer)
|
52
|
+
- [10. Other Language Plugins](#10-other-language-plugins)
|
40
53
|
|
41
54
|
## 1. Current Release Notice
|
42
55
|
|
43
|
-
1.
|
44
|
-
|
45
|
-
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.
|
46
|
-
|
47
|
-
The plugin now works with Jekyll 3, but it's backward compatible with Jekyll 2.
|
48
|
-
Please note that it was only tested with Jekyll 2.5.3 and 3.1.3.
|
56
|
+
1.6.0 is the current stable release.
|
49
57
|
|
50
58
|
The support for Octopress is dropped, but the plugin should still work with it since Octopress core is Jekyll.
|
51
59
|
Octopress 3 now has its own multi languages plugin: https://github.com/octopress/multilingual
|
@@ -53,7 +61,6 @@ Octopress 3 now has its own multi languages plugin: https://github.com/octopress
|
|
53
61
|
|
54
62
|
|
55
63
|
## 2. Features
|
56
|
-
* Works with Jekyll 2.5.3 and 3.1.3
|
57
64
|
* Supports multiple languages with the same code base.
|
58
65
|
* Supports all template languages that your Liquid pipeline supports.
|
59
66
|
* Uses [Liquid tags](https://github.com/Shopify/liquid) in your HTML for including translated strings.
|
@@ -82,10 +89,10 @@ And then execute: `$ bundle install`
|
|
82
89
|
|
83
90
|
Or install it yourself as: `$ gem install jekyll-multiple-languages-plugin`
|
84
91
|
|
85
|
-
To activate the plugin add it to the Jekyll `_config.yml` file, under the `
|
92
|
+
To activate the plugin add it to the Jekyll `_config.yml` file, under the `plugins` option:
|
86
93
|
|
87
94
|
```ruby
|
88
|
-
|
95
|
+
plugins:
|
89
96
|
- jekyll-multiple-languages-plugin
|
90
97
|
```
|
91
98
|
See the [Jekyll configuration documentation](http://jekyllrb.com/docs/configuration) for details.
|
@@ -135,6 +142,12 @@ In code, these specific files should be referenced via `baseurl_root`. E.g.
|
|
135
142
|
<link rel="stylesheet" href="{{ "/css/bootstrap.css" | prepend: site.baseurl_root }}"/>
|
136
143
|
```
|
137
144
|
|
145
|
+
If you wish to avoid having the default_lang built into the root of your website, use:
|
146
|
+
|
147
|
+
```yaml
|
148
|
+
default_locale_in_subfolder: true
|
149
|
+
```
|
150
|
+
|
138
151
|
### 4.2. Folder structure
|
139
152
|
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`:
|
140
153
|
|
@@ -172,7 +185,7 @@ pages:
|
|
172
185
|
work: Work
|
173
186
|
```
|
174
187
|
|
175
|
-
To access the `english` key, use one of these
|
188
|
+
To access the `english` key, use one of these tags:
|
176
189
|
|
177
190
|
```liquid
|
178
191
|
{% t global.english %}
|
@@ -180,14 +193,36 @@ or
|
|
180
193
|
{% translate global.english %}
|
181
194
|
```
|
182
195
|
|
183
|
-
You can also access translated strings by
|
196
|
+
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:
|
184
197
|
|
185
198
|
```liquid
|
186
|
-
{% for item in site.translations[site.lang]
|
199
|
+
{% for item in site.translations[site.lang].my_nested_yaml_collection %}
|
187
200
|
<p>{{ item[0] }} -> {{ item[1] }}</p>
|
188
201
|
{% endfor %}
|
189
202
|
```
|
190
203
|
|
204
|
+
or the translated string's assignment:
|
205
|
+
|
206
|
+
```yaml
|
207
|
+
my_nested_yaml_collection:
|
208
|
+
-
|
209
|
+
title: First
|
210
|
+
message: Message
|
211
|
+
-
|
212
|
+
title: Second
|
213
|
+
message: Message
|
214
|
+
|
215
|
+
```
|
216
|
+
|
217
|
+
```liquid
|
218
|
+
{% for item in site.translations[site.lang].my_nested_yaml_collection %}
|
219
|
+
<li>
|
220
|
+
<h2>{{ item["title"] }}</h2>
|
221
|
+
<p>{{ item["message"] }}</p>
|
222
|
+
</li>
|
223
|
+
{% endfor %}
|
224
|
+
```
|
225
|
+
|
191
226
|
### 5.2. Including translated files
|
192
227
|
The plugin also supports using different markdown files for different languages using the liquid tag:
|
193
228
|
|
@@ -272,7 +307,7 @@ titles:
|
|
272
307
|
This plugin gives you the variables
|
273
308
|
|
274
309
|
```liquid
|
275
|
-
{{
|
310
|
+
{{ site.lang }}
|
276
311
|
|
277
312
|
and
|
278
313
|
|
@@ -286,7 +321,7 @@ This allows you to create solutions like this:
|
|
286
321
|
|
287
322
|
``` liquid
|
288
323
|
{% if site.lang == "sv" %}
|
289
|
-
{% capture link1 %}{{ site.baseurl_root }}en{{ page.url}}{% endcapture %}
|
324
|
+
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
|
290
325
|
<a href="{{ link1 }}" >{% t global.english %}</a>
|
291
326
|
{% elsif site.lang == "en" %}
|
292
327
|
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
|
@@ -322,6 +357,31 @@ Inside each of the language folders, you should create mirror pages to provide t
|
|
322
357
|
|
323
358
|
|
324
359
|
|
360
|
+
### 5.7. Creating posts
|
361
|
+
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.
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
### 5.8. Select pages to translations
|
366
|
+
|
367
|
+
Sometimes you want to generate only selected versions of the page, especially excluding default language. You can do this using languages tag.
|
368
|
+
|
369
|
+
Example:
|
370
|
+
```yaml
|
371
|
+
---
|
372
|
+
permalink: /team/
|
373
|
+
permalink_fr: /equipe/
|
374
|
+
|
375
|
+
languages: ["fr"]
|
376
|
+
---
|
377
|
+
```
|
378
|
+
|
379
|
+
This generate only french version of the page.
|
380
|
+
|
381
|
+
## 6. License
|
382
|
+
|
383
|
+
This project is available under the [MIT License](LICENSE.txt).
|
384
|
+
|
325
385
|
## 7. Example website
|
326
386
|
|
327
387
|
This repository has an example website where you can test the plugin.
|
@@ -355,8 +415,25 @@ permalink: /about/
|
|
355
415
|
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.
|
356
416
|
|
357
417
|
|
358
|
-
|
359
418
|
## 8. Changelog
|
419
|
+
* 1.8.0
|
420
|
+
* I18n for site and Front Matter configurations [@pgoltsev](https://github.com/kurtsson/jekyll-multiple-languages-plugin/pull/125)
|
421
|
+
* 1.7.0
|
422
|
+
* Option to build the default language into a subfolder
|
423
|
+
* Configurable verbosity
|
424
|
+
* Improved documentation
|
425
|
+
* Removed deprecation warning
|
426
|
+
* 1.6.1
|
427
|
+
* Improved testing
|
428
|
+
* Support for Jekyll 4
|
429
|
+
* Russian examples
|
430
|
+
* Translations rebuilt every time page is reloaded in developer mode
|
431
|
+
* 1.6.0
|
432
|
+
* fix: check if static_file_r_path is set
|
433
|
+
* Missing slash before lang prefix in lang picker example
|
434
|
+
* Updated README.md with _posts directory
|
435
|
+
* Build translations in pre_render hook
|
436
|
+
* If include not found, fall back to default language
|
360
437
|
* 1.5.1
|
361
438
|
* Fix a bug (#70) where `site.static_files` would be empty on subsites if `exclude_from_localizations` is used.
|
362
439
|
* Some overall project enhancements and minor fixes.
|
@@ -369,8 +446,8 @@ Then, create a file named `about.md` under `_i18n/en` with the English content.
|
|
369
446
|
* 1.4.1
|
370
447
|
* Fixes a bug during site regeneration where translation paths were being nested based on wrongly set Jekyll variables.
|
371
448
|
* 1.4.0
|
372
|
-
* Support for Jekyll 3, thanks to [@pedrocarmona](https://github.com/
|
373
|
-
* How to create pages documentation, thanks to [@elotroalex](https://github.com/
|
449
|
+
* Support for Jekyll 3, thanks to [@pedrocarmona](https://github.com/kurtsson/jekyll-multiple-languages-plugin/pull/62)
|
450
|
+
* How to create pages documentation, thanks to [@elotroalex](https://github.com/kurtsson/jekyll-multiple-languages-plugin/pull/57)
|
374
451
|
* Many bug fixes
|
375
452
|
* Code refactoring, cleanup and reorganization
|
376
453
|
* Files and folders reorganization
|
@@ -378,8 +455,8 @@ Then, create a file named `about.md` under `_i18n/en` with the English content.
|
|
378
455
|
* Improvements and fixes on documentations
|
379
456
|
* Improved license files
|
380
457
|
* 1.3.0
|
381
|
-
* Support for localized links and custom permalinks, thanks to [@jasonlemay](https://github.com/
|
382
|
-
* Support for excluding posts from translation, thanks to [@ctruelson](https://github.com/
|
458
|
+
* Support for localized links and custom permalinks, thanks to [@jasonlemay](https://github.com/kurtsson/jekyll-multiple-languages-plugin/pull/53)
|
459
|
+
* Support for excluding posts from translation, thanks to [@ctruelson](https://github.com/kurtsson/jekyll-multiple-languages-plugin/pull/51)
|
383
460
|
* 1.2.9
|
384
461
|
* Bug fix when excluding files from translation, again thanks to [@h6](https://github.com/H6)
|
385
462
|
* 1.2.8
|
@@ -422,6 +499,7 @@ Then, create a file named `about.md` under `_i18n/en` with the English content.
|
|
422
499
|
### Contributors
|
423
500
|
| User | Contribution |
|
424
501
|
| :----------------------------------------------- | :----------------------------------- |
|
502
|
+
| [@pgoltsev](https://github.com/pgoltsev) | version 1.8.0
|
425
503
|
| [@pedrocarmona](https://github.com/pedrocarmona) | support for Jekyll 3 |
|
426
504
|
| [@elotroalex](https://github.com/elotroalex) | added a how to create page to README |
|
427
505
|
| [@mohamnag](https://github.com/mohamnag) | permalink generation bug fix |
|
@@ -434,29 +512,28 @@ Then, create a file named `about.md` under `_i18n/en` with the English content.
|
|
434
512
|
| [@leoditommaso](https://github.com/leoditommaso) | update the example page |
|
435
513
|
|
436
514
|
### Created by
|
437
|
-
[@kurtsson](https://github.com/kurtsson) from [
|
438
|
-
|
515
|
+
[@kurtsson](https://github.com/kurtsson) from [Daresay](https://github.com/daresaydigital) (https://daresay.co)
|
439
516
|
|
440
517
|
### Maintained by
|
441
|
-
- [@
|
518
|
+
- [@shushugah](https://github.com/shushugah)
|
519
|
+
|
520
|
+
### Former maintainer
|
442
521
|
- [@Anthony-Gaudino](https://github.com/Anthony-Gaudino)
|
443
522
|
|
444
523
|
|
445
524
|
|
446
525
|
## 10. Other Language Plugins
|
447
|
-
|
526
|
+
Below is a list of other language plugins for Jekyll (2019/06/27):
|
448
527
|
|
449
528
|
**Seems to be maintained:**
|
450
|
-
|
451
|
-
* [Jekyll Language Plugin](https://github.com/vwochnik/jekyll-language-plugin)
|
452
529
|
* [Polyglot](https://github.com/untra/polyglot)
|
453
|
-
* [Jekyll
|
454
|
-
* [Octopress Multilingual](https://github.com/octopress/multilingual)
|
455
|
-
* [jekyll-i18n_tags](https://github.com/KrzysiekJ/jekyll-i18n_tags)
|
530
|
+
* [Jekyll Language Plugin](https://github.com/vwochnik/jekyll-language-plugin)
|
456
531
|
* [jekyll-task-i18n](https://github.com/ruby-gettext/jekyll-task-i18n)
|
457
532
|
|
458
533
|
**Seems to be unmaintained / abandoned:**
|
459
|
-
|
534
|
+
* [jekyll-i18n_tags](https://github.com/KrzysiekJ/jekyll-i18n_tags)
|
535
|
+
* [Octopress Multilingual](https://github.com/octopress/multilingual)
|
536
|
+
* [Jekyll Multiple Languages](https://github.com/liaohuqiu/jekyll-multiple-languages)
|
460
537
|
* [Jekyll-Multilingualism](https://github.com/aleiphoenix/jekyll-multilingualism)
|
461
538
|
* [Jekyll::Languages](https://github.com/janlindblom/jekyll-languages)
|
462
539
|
* [Jekyll I18n support](https://github.com/hendricius/jekyll-i18n)
|
@@ -19,6 +19,51 @@ module Jekyll
|
|
19
19
|
#*****************************************************************************
|
20
20
|
# :site, :post_render hook
|
21
21
|
#*****************************************************************************
|
22
|
+
Jekyll::Hooks.register :site, :pre_render do |site, payload|
|
23
|
+
lang = site.config['lang']
|
24
|
+
puts "Loading translation from file #{site.source}/_i18n/#{lang}.yml"
|
25
|
+
site.parsed_translations[lang] = YAML.load_file("#{site.source}/_i18n/#{lang}.yml")
|
26
|
+
end
|
27
|
+
|
28
|
+
#*****************************************************************************
|
29
|
+
# :site, :post_write hook
|
30
|
+
#*****************************************************************************
|
31
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
32
|
+
|
33
|
+
# Moves excluded paths from the default lang subfolder to the root folder
|
34
|
+
#===========================================================================
|
35
|
+
default_lang = site.config["default_lang"]
|
36
|
+
current_lang = site.config["lang"]
|
37
|
+
exclude_paths = site.config["exclude_from_localizations"]
|
38
|
+
|
39
|
+
if (default_lang == current_lang && site.config["default_locale_in_subfolder"])
|
40
|
+
files = Dir.glob(File.join("_site/" + current_lang + "/", "*"))
|
41
|
+
files.each do |file_path|
|
42
|
+
parts = file_path.split('/')
|
43
|
+
f_path = parts[2..-1].join('/')
|
44
|
+
if (f_path == 'base.html')
|
45
|
+
new_path = parts[0] + "/index.html"
|
46
|
+
puts "Moving '" + file_path + "' to '" + new_path + "'"
|
47
|
+
File.rename file_path, new_path
|
48
|
+
else
|
49
|
+
exclude_paths.each do |exclude_path|
|
50
|
+
if (exclude_path == f_path)
|
51
|
+
new_path = parts[0] + "/" + f_path
|
52
|
+
puts "Moving '" + file_path + "' to '" + new_path + "'"
|
53
|
+
if (Dir.exists?(new_path))
|
54
|
+
FileUtils.rm_r new_path
|
55
|
+
end
|
56
|
+
File.rename file_path, new_path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
#===========================================================================
|
64
|
+
|
65
|
+
end
|
66
|
+
|
22
67
|
Jekyll::Hooks.register :site, :post_render do |site, payload|
|
23
68
|
|
24
69
|
# Removes all static files that should not be copied to translated sites.
|
@@ -29,17 +74,23 @@ module Jekyll
|
|
29
74
|
static_files = payload["site"]["static_files"]
|
30
75
|
exclude_paths = payload["site"]["exclude_from_localizations"]
|
31
76
|
|
77
|
+
default_locale_in_subfolder = site.config["default_locale_in_subfolder"]
|
32
78
|
|
33
79
|
if default_lang != current_lang
|
34
80
|
static_files.delete_if do |static_file|
|
35
|
-
|
81
|
+
next true if (static_file.name == 'base.html' && default_locale_in_subfolder)
|
82
|
+
|
36
83
|
# Remove "/" from beginning of static file relative path
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
84
|
+
if static_file.instance_variable_get(:@relative_path) != nil
|
85
|
+
static_file_r_path = static_file.instance_variable_get(:@relative_path).dup
|
86
|
+
if static_file_r_path
|
87
|
+
static_file_r_path[0] = ''
|
88
|
+
|
89
|
+
exclude_paths.any? do |exclude_path|
|
90
|
+
Pathname.new(static_file_r_path).descend do |static_file_path|
|
91
|
+
break(true) if (Pathname.new(exclude_path) <=> static_file_path) == 0
|
92
|
+
end
|
93
|
+
end
|
43
94
|
end
|
44
95
|
end
|
45
96
|
end
|
@@ -49,7 +100,17 @@ module Jekyll
|
|
49
100
|
|
50
101
|
end
|
51
102
|
|
103
|
+
#*****************************************************************************
|
104
|
+
# :site, :pre_render hook
|
105
|
+
#*****************************************************************************
|
106
|
+
Jekyll::Hooks.register :site, :pre_render do |site, payload|
|
52
107
|
|
108
|
+
# Localize front matter data of every page.
|
109
|
+
#===========================================================================
|
110
|
+
(site.pages + site.documents).each do |item|
|
111
|
+
translate_props(item.data, site)
|
112
|
+
end
|
113
|
+
end
|
53
114
|
|
54
115
|
##############################################################################
|
55
116
|
# class Site
|
@@ -72,6 +133,8 @@ module Jekyll
|
|
72
133
|
self.parsed_translations ||= {}
|
73
134
|
|
74
135
|
self.config['exclude_from_localizations'] ||= []
|
136
|
+
|
137
|
+
self.config['default_locale_in_subfolder'] ||= false
|
75
138
|
|
76
139
|
if ( !self.config['languages'] or
|
77
140
|
self.config['languages'].empty? or
|
@@ -87,8 +150,8 @@ module Jekyll
|
|
87
150
|
#-------------------------------------------------------------------------
|
88
151
|
|
89
152
|
# Original Jekyll configurations
|
90
|
-
baseurl_org = self.config[ 'baseurl' ] # Baseurl set on _config.yml
|
91
|
-
dest_org = self.dest
|
153
|
+
baseurl_org = self.config[ 'baseurl' ].to_s # Baseurl set on _config.yml
|
154
|
+
dest_org = self.dest # Destination folder where the website is generated
|
92
155
|
|
93
156
|
# Site building only variables
|
94
157
|
languages = self.config['languages'] # List of languages set on _config.yml
|
@@ -99,27 +162,24 @@ module Jekyll
|
|
99
162
|
self.config['baseurl_root'] = baseurl_org # Baseurl of website root (without the appended language code)
|
100
163
|
self.config['translations'] = self.parsed_translations # Hash that stores parsed translations read from YAML files. Exposes this hash to Liquid.
|
101
164
|
|
102
|
-
|
103
|
-
# Build the website for default language
|
104
|
-
#-------------------------------------------------------------------------
|
105
|
-
puts "Building site for default language: \"#{self.config['lang']}\" to: #{self.dest}"
|
106
|
-
|
107
|
-
process_org
|
108
|
-
|
109
|
-
|
110
|
-
# Build the website for the other languages
|
165
|
+
# Build the website for all languages
|
111
166
|
#-------------------------------------------------------------------------
|
112
167
|
|
113
168
|
# Remove .htaccess file from included files, so it wont show up on translations folders.
|
114
169
|
self.include -= [".htaccess"]
|
115
170
|
|
116
|
-
languages.
|
171
|
+
languages.each do |lang|
|
117
172
|
|
118
173
|
# Language specific config/variables
|
119
|
-
|
120
|
-
|
121
|
-
|
174
|
+
if lang != self.config['default_lang'] || self.config['default_locale_in_subfolder']
|
175
|
+
@dest = dest_org + "/" + lang
|
176
|
+
self.config['baseurl'] = baseurl_org + "/" + lang
|
177
|
+
self.config['lang'] = lang
|
178
|
+
end
|
122
179
|
|
180
|
+
# Translate site attributes to current language
|
181
|
+
translate_props(self.config, self)
|
182
|
+
|
123
183
|
puts "Building site for language: \"#{self.config['lang']}\" to: #{self.dest}"
|
124
184
|
|
125
185
|
process_org
|
@@ -156,6 +216,26 @@ module Jekyll
|
|
156
216
|
|
157
217
|
|
158
218
|
|
219
|
+
##############################################################################
|
220
|
+
# class PageReader
|
221
|
+
##############################################################################
|
222
|
+
class PageReader
|
223
|
+
alias :read_org :read
|
224
|
+
|
225
|
+
#======================================
|
226
|
+
# read
|
227
|
+
#
|
228
|
+
# Monkey patched this method to remove excluded languages.
|
229
|
+
#======================================
|
230
|
+
def read(files)
|
231
|
+
read_org(files).reject do |page|
|
232
|
+
page.data['languages'] && !page.data['languages'].include?(site.config['lang'])
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
|
159
239
|
##############################################################################
|
160
240
|
# class PostReader
|
161
241
|
##############################################################################
|
@@ -180,11 +260,14 @@ module Jekyll
|
|
180
260
|
|
181
261
|
|
182
262
|
|
183
|
-
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
|
263
|
+
#-----------------------------------------------------------------------------
|
264
|
+
#
|
265
|
+
# Include (with priority—prepend)the translated
|
266
|
+
# permanent link for Page and document
|
267
|
+
#
|
268
|
+
#-----------------------------------------------------------------------------
|
269
|
+
|
270
|
+
module Permalink
|
188
271
|
#======================================
|
189
272
|
# permalink
|
190
273
|
#======================================
|
@@ -193,14 +276,18 @@ module Jekyll
|
|
193
276
|
|
194
277
|
if site.config['relative_permalinks']
|
195
278
|
File.join(@dir, data['permalink'])
|
196
|
-
|
279
|
+
elsif site.config['lang']
|
197
280
|
# Look if there's a permalink overwrite specified for this lang
|
198
|
-
data['permalink_'+site.config['lang']] || data['permalink']
|
281
|
+
data['permalink_' + site.config['lang']] || data['permalink']
|
282
|
+
else
|
283
|
+
data['permalink']
|
199
284
|
end
|
200
285
|
|
201
286
|
end
|
202
287
|
end
|
203
288
|
|
289
|
+
Page.prepend(Permalink)
|
290
|
+
Document.prepend(Permalink)
|
204
291
|
|
205
292
|
|
206
293
|
##############################################################################
|
@@ -305,19 +392,18 @@ module Jekyll
|
|
305
392
|
|
306
393
|
lang = site.config['lang']
|
307
394
|
|
308
|
-
unless site.parsed_translations.has_key?(lang)
|
309
|
-
puts "Loading translation from file #{site.source}/_i18n/#{lang}.yml"
|
310
|
-
site.parsed_translations[lang] = YAML.load_file("#{site.source}/_i18n/#{lang}.yml")
|
311
|
-
end
|
312
|
-
|
313
395
|
translation = site.parsed_translations[lang].access(key) if key.is_a?(String)
|
314
396
|
|
315
397
|
if translation.nil? or translation.empty?
|
316
398
|
translation = site.parsed_translations[site.config['default_lang']].access(key)
|
317
399
|
|
318
|
-
|
319
|
-
|
400
|
+
if site.config["verbose"]
|
401
|
+
puts "Missing i18n key: #{lang}:#{key}"
|
402
|
+
puts "Using translation '%s' from default language: %s" %[translation, site.config['default_lang']]
|
403
|
+
end
|
320
404
|
end
|
405
|
+
|
406
|
+
TranslatedString.translate(key, lang, site)
|
321
407
|
|
322
408
|
translation
|
323
409
|
end
|
@@ -348,9 +434,24 @@ module Jekyll
|
|
348
434
|
|
349
435
|
site = context.registers[:site] # Jekyll site object
|
350
436
|
|
351
|
-
|
352
|
-
|
437
|
+
default_lang = site.config['default_lang']
|
438
|
+
|
353
439
|
validate_file_name(file)
|
440
|
+
|
441
|
+
includes_dir = File.join(site.source, '_i18n/' + site.config['lang'])
|
442
|
+
|
443
|
+
# If directory doesn't exist, go to default lang
|
444
|
+
if !Dir.exist?(includes_dir)
|
445
|
+
includes_dir = File.join(site.source, '_i18n/' + default_lang)
|
446
|
+
elsif
|
447
|
+
# If file doesn't exist, go to default lang
|
448
|
+
Dir.chdir(includes_dir) do
|
449
|
+
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
450
|
+
if !choices.include?( file)
|
451
|
+
includes_dir = File.join(site.source, '_i18n/' + default_lang)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
354
455
|
|
355
456
|
Dir.chdir(includes_dir) do
|
356
457
|
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
@@ -376,6 +477,25 @@ module Jekyll
|
|
376
477
|
end
|
377
478
|
end
|
378
479
|
end
|
480
|
+
|
481
|
+
# Override of core Jekyll functionality, to get rid of deprecation
|
482
|
+
# warning. See https://github.com/jekyll/jekyll/pull/7117 for more
|
483
|
+
# details.
|
484
|
+
class PostComparer
|
485
|
+
def initialize(name)
|
486
|
+
@name = name
|
487
|
+
|
488
|
+
all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER)
|
489
|
+
unless all
|
490
|
+
raise Jekyll::Errors::InvalidPostNameError,
|
491
|
+
"'#{name}' does not contain valid date and/or title."
|
492
|
+
end
|
493
|
+
|
494
|
+
escaped_slug = Regexp.escape(slug)
|
495
|
+
@name_regex = %r!_posts/#{path}#{date}-#{escaped_slug}\.[^.]+|
|
496
|
+
^#{path}_posts/?#{date}-#{escaped_slug}\.[^.]+!x
|
497
|
+
end
|
498
|
+
end
|
379
499
|
end
|
380
500
|
|
381
501
|
|
@@ -420,10 +540,13 @@ module Jekyll
|
|
420
540
|
pages = site.pages
|
421
541
|
url = "";
|
422
542
|
|
423
|
-
if default_lang != lang
|
543
|
+
if default_lang != lang || site.config['default_locale_in_subfolder']
|
424
544
|
baseurl = baseurl + "/" + lang
|
425
545
|
end
|
426
546
|
|
547
|
+
collections = site.collections.values.collect{|x| x.docs}.flatten
|
548
|
+
pages = site.pages + collections
|
549
|
+
|
427
550
|
for p in pages
|
428
551
|
unless p['namespace'].nil?
|
429
552
|
page_namespace = p['namespace']
|
@@ -474,6 +597,86 @@ end
|
|
474
597
|
|
475
598
|
|
476
599
|
|
600
|
+
#======================================
|
601
|
+
# translate_key
|
602
|
+
#
|
603
|
+
# Translate given key to given language.
|
604
|
+
#======================================
|
605
|
+
def translate_key(key, lang, site)
|
606
|
+
unless site.parsed_translations.has_key?(lang)
|
607
|
+
puts "Loading translation from file #{site.source}/_i18n/#{lang}.yml"
|
608
|
+
site.parsed_translations[lang] = YAML.load_file("#{site.source}/_i18n/#{lang}.yml")
|
609
|
+
end
|
610
|
+
|
611
|
+
translation = site.parsed_translations[lang].access(key) if key.is_a?(String)
|
612
|
+
|
613
|
+
if translation.nil? or translation.empty?
|
614
|
+
translation = site.parsed_translations[site.config['default_lang']].access(key)
|
615
|
+
|
616
|
+
puts "Missing i18n key: #{lang}:#{key}"
|
617
|
+
puts "Using translation '%s' from default language: %s" %[translation, site.config['default_lang']]
|
618
|
+
end
|
619
|
+
|
620
|
+
translation
|
621
|
+
end
|
622
|
+
|
623
|
+
|
624
|
+
################################################################################
|
625
|
+
# class TranslatedString
|
626
|
+
################################################################################
|
627
|
+
class TranslatedString < String
|
628
|
+
#======================================
|
629
|
+
# initialize
|
630
|
+
#======================================
|
631
|
+
def initialize(*several_variants, key)
|
632
|
+
super(*several_variants)
|
633
|
+
@key = key
|
634
|
+
end
|
635
|
+
|
636
|
+
def key
|
637
|
+
@key
|
638
|
+
end
|
639
|
+
|
640
|
+
#======================================
|
641
|
+
# translate
|
642
|
+
#======================================
|
643
|
+
def self.translate(str, lang, site)
|
644
|
+
if str.is_a?(TranslatedString)
|
645
|
+
key = str.key
|
646
|
+
else
|
647
|
+
key = str
|
648
|
+
end
|
649
|
+
return TranslatedString.new(translate_key(key, lang, site), key = key)
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
|
654
|
+
#======================================
|
655
|
+
# translate_props
|
656
|
+
#
|
657
|
+
# Perform translation of properties defined in translation property list.
|
658
|
+
#======================================
|
659
|
+
def translate_props(data, site, props_key_name = 'translate_props')
|
660
|
+
lang = site.config['lang']
|
661
|
+
(data[props_key_name] || []).each do |prop_name|
|
662
|
+
if prop_name.is_a?(String)
|
663
|
+
prop_name = prop_name.strip
|
664
|
+
if prop_name.empty?
|
665
|
+
puts "There is an empty property defined in '#{props_key_name}'"
|
666
|
+
else
|
667
|
+
prop_value = data[prop_name]
|
668
|
+
if prop_value.is_a?(String) and !prop_value.empty?
|
669
|
+
data[prop_name] = TranslatedString.translate(prop_value, lang, site)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
else
|
673
|
+
puts "Incorrect property name '#{prop_name}'. Must be a string"
|
674
|
+
end
|
675
|
+
end
|
676
|
+
end
|
677
|
+
|
678
|
+
|
679
|
+
|
477
680
|
################################################################################
|
478
681
|
# Liquid tags definitions
|
479
682
|
|
@@ -483,4 +686,3 @@ Liquid::Template.register_tag('tf', Jekyll::Tags::LocalizeInclude)
|
|
483
686
|
Liquid::Template.register_tag('translate_file', Jekyll::Tags::LocalizeInclude)
|
484
687
|
Liquid::Template.register_tag('tl', Jekyll::LocalizeLink )
|
485
688
|
Liquid::Template.register_tag('translate_link', Jekyll::LocalizeLink )
|
486
|
-
|
data/lib/plugin/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-multiple-languages-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Kurtsson
|
8
|
-
|
8
|
+
- Yonatan Miller
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: html-proofer
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "
|
18
|
+
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
+
version: '0'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - "
|
25
|
+
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
+
version: '0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
version: 12.3.3
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - "
|
39
|
+
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
+
version: 12.3.3
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: jekyll
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,7 +48,7 @@ dependencies:
|
|
47
48
|
version: '2.0'
|
48
49
|
- - "<"
|
49
50
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
51
|
+
version: '5.0'
|
51
52
|
type: :runtime
|
52
53
|
prerelease: false
|
53
54
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -57,12 +58,12 @@ dependencies:
|
|
57
58
|
version: '2.0'
|
58
59
|
- - "<"
|
59
60
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
+
version: '5.0'
|
61
62
|
description: Plugin for Jekyll 2.x and 3.x that adds support for translated keys,
|
62
63
|
templates and posts.
|
63
64
|
email:
|
64
|
-
- martin.kurtsson@
|
65
|
-
-
|
65
|
+
- martin.kurtsson@daresay.co
|
66
|
+
- yonatan@shushugah.com
|
66
67
|
executables: []
|
67
68
|
extensions: []
|
68
69
|
extra_rdoc_files:
|
@@ -73,11 +74,11 @@ files:
|
|
73
74
|
- README.md
|
74
75
|
- lib/jekyll-multiple-languages-plugin.rb
|
75
76
|
- lib/plugin/version.rb
|
76
|
-
homepage: https://github.com/
|
77
|
+
homepage: https://github.com/kurtsson/jekyll-multiple-languages-plugin/
|
77
78
|
licenses:
|
78
|
-
-
|
79
|
+
- MIT
|
79
80
|
metadata: {}
|
80
|
-
post_install_message:
|
81
|
+
post_install_message:
|
81
82
|
rdoc_options:
|
82
83
|
- "--charset=UTF-8"
|
83
84
|
require_paths:
|
@@ -93,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
94
|
- !ruby/object:Gem::Version
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
signing_key:
|
97
|
+
rubygems_version: 3.0.3.1
|
98
|
+
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: I18n plugin for Jekyll
|
101
101
|
test_files: []
|