jekyll-localization 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/README +1 -1
- data/lib/jekyll/localization.rb +58 -21
- data/lib/jekyll/localization/version.rb +1 -1
- metadata +10 -10
data/ChangeLog
CHANGED
data/README
CHANGED
data/lib/jekyll/localization.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
#--
|
2
4
|
###############################################################################
|
3
5
|
# #
|
@@ -44,15 +46,41 @@ module Jekyll
|
|
44
46
|
'fr' => %w[French Französisch Français]
|
45
47
|
}
|
46
48
|
|
47
|
-
|
48
|
-
'
|
49
|
-
|
50
|
-
}
|
49
|
+
DATE_FMT = Hash.new { |h, k| h[k] = '%a %e %b %Y %M:%M:%S %Z' }.update(
|
50
|
+
'en' => '%a %e %b %Y %M:%M:%S %p %Z'
|
51
|
+
)
|
51
52
|
|
52
|
-
|
53
|
-
'de' => %
|
54
|
-
|
55
|
-
|
53
|
+
DATE_FMT_LONG = Hash.new { |h, k| h[k] = '%e %B %Y' }.update(
|
54
|
+
'de' => '%e. %B %Y'
|
55
|
+
)
|
56
|
+
|
57
|
+
DATE_FMT_SHORT = Hash.new { |h, k| h[k] = '%e %b %Y' }.update(
|
58
|
+
'de' => '%e. %b %Y'
|
59
|
+
)
|
60
|
+
|
61
|
+
MONTHNAMES = Hash.new { |h, k| h[k] = Date::MONTHNAMES }.update(
|
62
|
+
'de' => [nil] + %w[Januar Februar März April Mai Juni Juli August September Oktober November Dezember],
|
63
|
+
'fr' => [nil] + %w[janvier février mars avril mai juin juillet août septembre octobre novembre décembre]
|
64
|
+
)
|
65
|
+
|
66
|
+
ABBR_MONTHNAMES = Hash.new { |h, k| h[k] = Date::ABBR_MONTHNAMES }.update(
|
67
|
+
'de' => [nil] + %w[Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez],
|
68
|
+
'fr' => [nil] + %w[janv. fév. mars avril mai juin juil. août sept. oct. nov. déc.]
|
69
|
+
)
|
70
|
+
|
71
|
+
DAYNAMES = Hash.new { |h, k| h[k] = Date::DAYNAMES }.update(
|
72
|
+
'de' => %w[Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag],
|
73
|
+
'fr' => %w[dimanche lundi mardi mercredi jeudi vendredi samedi]
|
74
|
+
)
|
75
|
+
|
76
|
+
ABBR_DAYNAMES = Hash.new { |h, k| h[k] = Date::ABBR_DAYNAMES }.update(
|
77
|
+
'de' => %w[So Mo Di Mi Do Fr Sa],
|
78
|
+
'fr' => %w[dim. lun. mar. mer. jeu. ven. sam.]
|
79
|
+
)
|
80
|
+
|
81
|
+
MERIDIAN = Hash.new { |h, k| h[k] = ['', ''] }.update(
|
82
|
+
'en' => %w[AM PM]
|
83
|
+
)
|
56
84
|
|
57
85
|
# What is considered a language extension
|
58
86
|
LANG_EXT_RE = %r{\.([a-z]{2})}
|
@@ -187,7 +215,7 @@ module Jekyll
|
|
187
215
|
|
188
216
|
yield
|
189
217
|
ensure
|
190
|
-
site.posts.replace(original_posts) if original_posts &&
|
218
|
+
site.posts.replace(original_posts) if original_posts && lang
|
191
219
|
end
|
192
220
|
|
193
221
|
end
|
@@ -265,27 +293,36 @@ module Jekyll
|
|
265
293
|
|
266
294
|
# Overwrites the original method to generate localized date strings.
|
267
295
|
def date_to_string(date, lang = lang)
|
268
|
-
local_date_string(date,
|
296
|
+
local_date_string(date, Localization::DATE_FMT_SHORT[lang], lang)
|
269
297
|
end
|
270
298
|
|
271
299
|
alias_method :_localization_original_date_to_long_string, :date_to_long_string
|
272
300
|
|
273
301
|
# Overwrites the original method to generate localized date strings.
|
274
302
|
def date_to_long_string(date, lang = lang)
|
275
|
-
local_date_string(date,
|
303
|
+
local_date_string(date, Localization::DATE_FMT_LONG[lang], lang)
|
276
304
|
end
|
277
305
|
|
278
|
-
def local_date_string(date,
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
306
|
+
def local_date_string(date, fmt, lang = lang)
|
307
|
+
# unabashedly stole this snippet from Joshua Harvey's Globalize plugin,
|
308
|
+
# which itself unabashedly stole it from Tadayoshi Funaba's Date class
|
309
|
+
res = ''
|
310
|
+
|
311
|
+
fmt.scan(/%[EO]?(.)|(.)/o) { |a, b|
|
312
|
+
res << case a
|
313
|
+
when nil then b
|
314
|
+
when 'A' then Localization::DAYNAMES[lang][date.wday]
|
315
|
+
when 'a' then Localization::ABBR_DAYNAMES[lang][date.wday]
|
316
|
+
when 'B' then Localization::MONTHNAMES[lang][date.month]
|
317
|
+
when 'b' then Localization::ABBR_MONTHNAMES[lang][date.month]
|
318
|
+
when 'c' then local_date_string(date, Localization::DATE_FMT[lang], lang)
|
319
|
+
when 'P' then Localization::MERIDIAN[lang][date.send(:hour) < 12 ? 0 : 1].downcase
|
320
|
+
when 'p' then Localization::MERIDIAN[lang][date.send(:hour) < 12 ? 0 : 1]
|
321
|
+
else '%' << a
|
322
|
+
end
|
323
|
+
} if fmt
|
287
324
|
|
288
|
-
date.strftime(
|
325
|
+
date.strftime(res)
|
289
326
|
end
|
290
327
|
|
291
328
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-localization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jens Wille
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2012-04-18 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: jekyll-rendering
|
@@ -47,23 +47,23 @@ extra_rdoc_files:
|
|
47
47
|
files:
|
48
48
|
- lib/jekyll/localization/version.rb
|
49
49
|
- lib/jekyll/localization.rb
|
50
|
-
- Rakefile
|
51
|
-
- COPYING
|
52
50
|
- ChangeLog
|
51
|
+
- COPYING
|
53
52
|
- README
|
53
|
+
- Rakefile
|
54
54
|
homepage: http://github.com/blackwinter/jekyll-localization
|
55
55
|
licenses: []
|
56
56
|
|
57
57
|
post_install_message:
|
58
58
|
rdoc_options:
|
59
|
-
- --line-numbers
|
60
|
-
- --title
|
61
|
-
- jekyll-localization Application documentation (v0.1.3)
|
62
59
|
- --main
|
63
60
|
- README
|
64
61
|
- --charset
|
65
62
|
- UTF-8
|
66
63
|
- --all
|
64
|
+
- --title
|
65
|
+
- jekyll-localization Application documentation (v0.1.4)
|
66
|
+
- --line-numbers
|
67
67
|
require_paths:
|
68
68
|
- lib
|
69
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements: []
|
88
88
|
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.22
|
91
91
|
signing_key:
|
92
92
|
specification_version: 3
|
93
93
|
summary: Jekyll plugin that adds localization features to the rendering engine.
|