jekyll-localization 0.1.6 → 0.1.7

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: 9b67c96366b53e5e2659f7a65ecce74a842f9cd4
4
+ data.tar.gz: 8ac3645b43c4a10adfb9fb762132c2b4cc4359ea
5
+ SHA512:
6
+ metadata.gz: 577c1991f8450c879e98822ff38e7060fb55a5e9e23ec2282dd516f1b97a9be2e9c83f251522d561db2326d4287d5e3d82f6ef1add42b4b1ea545cd0131179d6
7
+ data.tar.gz: fd20283e377b3192b45f5607e63d22463d8e6ac9ef4407b0742094c56d869a740a167e24ee4d70f00b2799746e96491ea48f1d54c9dd1e04ed37b3679d2bc475
data/ChangeLog CHANGED
@@ -1,3 +1,5 @@
1
+ # markup: rd
2
+
1
3
  = Revision history for jekyll-localization
2
4
 
3
5
  == 0.1.6 [2012-05-24]
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to jekyll-localization version 0.1.6
5
+ This documentation refers to jekyll-localization version 0.1.7
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -32,14 +32,14 @@ Jekyll::Localization::HUMAN_LANGUAGES accordingly!
32
32
  == LINKS
33
33
 
34
34
  <b></b>
35
- Documentation:: http://rdoc.info/projects/blackwinter/jekyll-localization
35
+ Documentation:: http://blackwinter.github.com/jekyll-localization
36
36
  Source code:: http://github.com/blackwinter/jekyll-localization
37
37
  RubyGem:: http://rubygems.org/gems/jekyll-localization
38
38
 
39
39
 
40
40
  == AUTHORS
41
41
 
42
- * Jens Wille <mailto:jens.wille@uni-koeln.de>
42
+ * Jens Wille <mailto:jens.wille@gmail.com>
43
43
  * Arne Eilermann <mailto:eilermann@lavabit.com>
44
44
 
45
45
 
@@ -48,6 +48,8 @@ RubyGem:: http://rubygems.org/gems/jekyll-localization
48
48
  Copyright (C) 2010-2012 University of Cologne,
49
49
  Albertus-Magnus-Platz, 50923 Cologne, Germany
50
50
 
51
+ Copyright (C) 2013 Jens Wille
52
+
51
53
  jekyll-localization is free software: you can redistribute it and/or modify it
52
54
  under the terms of the GNU Affero General Public License as published by the
53
55
  Free Software Foundation, either version 3 of the License, or (at your option)
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  :version => Jekyll::Localization::VERSION,
10
10
  :summary => %q{Jekyll plugin that adds localization features to the rendering engine.},
11
11
  :authors => ['Jens Wille', 'Arne Eilermann'],
12
- :email => ['jens.wille@uni-koeln.de', 'eilermann@lavabit.com'],
12
+ :email => ['jens.wille@gmail.com', 'eilermann@lavabit.com'],
13
13
  :homepage => :blackwinter,
14
14
  :dependencies => %w[jekyll-rendering]
15
15
  }
@@ -10,8 +10,10 @@
10
10
  # Albertus-Magnus-Platz, #
11
11
  # 50923 Cologne, Germany #
12
12
  # #
13
+ # Copyright (C) 2013 Jens Wille #
14
+ # #
13
15
  # Authors: #
14
- # Jens Wille <jens.wille@uni-koeln.de> #
16
+ # Jens Wille <jens.wille@gmail.com> #
15
17
  # #
16
18
  # jekyll-localization is free software; you can redistribute it and/or modify #
17
19
  # it under the terms of the GNU Affero General Public License as published by #
@@ -46,39 +48,58 @@ module Jekyll
46
48
  'fr' => %w[French Französisch Français]
47
49
  }
48
50
 
49
- DATE_FMT = Hash.new { |h, k| h[k] = '%a %-d %b %Y %M:%M:%S %Z' }.update(
50
- 'en' => '%a %-d %b %Y %M:%M:%S %p %Z'
51
- )
51
+ # Path to I18n locale files (*.yml).
52
+ I18N_LOCALES = ENV['I18N_LOCALES'] || File.join(begin
53
+ [Gem::Specification.find_by_name('rails-i18n').gem_dir, 'rails']
54
+ rescue LoadError
55
+ __FILE__.chomp('.rb')
56
+ end, 'locale')
52
57
 
53
- DATE_FMT_LONG = Hash.new { |h, k| h[k] = '%-d %B %Y' }.update(
54
- 'de' => '%-d. %B %Y'
55
- )
58
+ # Cache for I18n locale information.
59
+ I18N = Hash.new { |h, k|
60
+ h[k] = YAML.load_file(File.join(I18N_LOCALES, "#{k}.yml"))[k] rescue nil
61
+ }
56
62
 
57
- DATE_FMT_SHORT = Hash.new { |h, k| h[k] = '%-d %b %Y' }.update(
58
- 'de' => '%-d. %b %Y'
59
- )
63
+ class << self
60
64
 
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
+ private
66
+
67
+ def i18n(key) # :nodoc:
68
+ key = key.split('.')
65
69
 
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.]
70
+ Hash.new { |h, k| h[k] = key.inject(I18N[k]) { |i, j|
71
+ if (v = i[j]).is_a?(Hash) then v else break v end
72
+ } }
73
+ end
74
+
75
+ end
76
+
77
+ TIME_FMT = i18n('time.formats.default').update(
78
+ 'en' => '%a %-d %b %Y %H:%M:%S %p %Z',
79
+ 'de' => '%a %-d %b %Y %H:%M:%S %Z'
69
80
  )
70
81
 
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]
82
+ # For backwards compatibility.
83
+ DATE_FMT = TIME_FMT
84
+
85
+ DATE_FMT_LONG = i18n('date.formats.long').update(
86
+ 'en' => '%-d %B %Y',
87
+ 'de' => '%-d. %B %Y'
74
88
  )
75
89
 
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.]
90
+ DATE_FMT_SHORT = i18n('date.formats.short').update(
91
+ 'en' => '%-d %b %Y',
92
+ 'de' => '%-d. %b %Y'
79
93
  )
80
94
 
81
- MERIDIAN = Hash.new { |h, k| h[k] = ['', ''] }.update(
95
+ MONTHNAMES = i18n('date.month_names')
96
+ ABBR_MONTHNAMES = i18n('date.abbr_month_names')
97
+ DAYNAMES = i18n('date.day_names')
98
+ ABBR_DAYNAMES = i18n('date.abbr_day_names')
99
+
100
+ MERIDIAN = Hash.new { |h, k|
101
+ h[k] = %w[am pm].map { |i| i18n("time.#{i}")[k] }
102
+ }.update(
82
103
  'en' => %w[AM PM]
83
104
  )
84
105
 
@@ -229,7 +250,9 @@ module Jekyll
229
250
 
230
251
  end
231
252
 
232
- class Pagination < Generator
253
+ parent = const_defined?(:Generators) ? Generators : self
254
+
255
+ class parent::Pagination < Generator
233
256
 
234
257
  include Helpers
235
258
 
@@ -277,12 +300,18 @@ module Jekyll
277
300
  end
278
301
 
279
302
  # call-seq:
280
- # t 'default', 'translation', ... => aString (Ruby-style)
281
- # 'default' | t: 'translation', ... => aString (Liquid-style)
303
+ # t 'default', 'translation', ... => aString (Ruby-style with array)
304
+ # 'default' | t: 'translation', ... => aString (Liquid-style with array)
305
+ # t 'en' => 'default', 'de' => 'translation', ... => aString (Ruby-style with hash)
306
+ # { 'en' => 'default', 'de' => 'translation', ... } | t => aString (Liquid-style with hash)
282
307
  #
283
- # Returns the argument whose position corresponds to the current
284
- # language's position in the Localization::LANGUAGES array. If that
285
- # particular argument is missing, +default+ is returned.
308
+ # If array given, returns the argument whose position corresponds to
309
+ # the current language's position in the Localization::LANGUAGES array.
310
+ # If that particular argument is missing, +default+ is returned.
311
+ #
312
+ # If hash given, returns the value for the current language. If that
313
+ # particular value is missing, the value for the default language is
314
+ # returned.
286
315
  def translate(*translations)
287
316
  translate_lang(lang, *translations)
288
317
  end
@@ -292,8 +321,19 @@ module Jekyll
292
321
  def translate_lang(lang, *translations)
293
322
  translations.flatten!
294
323
 
295
- index = Localization::LANGUAGES.index(lang)
296
- index && translations[index] || translations.first
324
+ if translations.last.is_a?(Hash)
325
+ hash = translations.pop
326
+
327
+ if translations.empty?
328
+ hash[key = lang] || hash[key.to_sym] ||
329
+ hash[key = Localization::LANGUAGES.first] || hash[key.to_sym]
330
+ else
331
+ raise ArgumentError, 'both hash and array given'
332
+ end
333
+ else
334
+ index = Localization::LANGUAGES.index(lang)
335
+ index && translations[index] || translations.first
336
+ end
297
337
  end
298
338
 
299
339
  alias_method :tl, :translate_lang
@@ -317,14 +357,14 @@ module Jekyll
317
357
  # which itself unabashedly stole it from Tadayoshi Funaba's Date class
318
358
  res = ''
319
359
 
320
- fmt.scan(/%[EO]?(.)|(.)/o) { |a, b|
360
+ fmt.scan(/%[EO]?(.)|(.)/) { |a, b|
321
361
  res << case a
322
362
  when nil then b
323
363
  when 'A' then Localization::DAYNAMES[lang][date.wday]
324
364
  when 'a' then Localization::ABBR_DAYNAMES[lang][date.wday]
325
365
  when 'B' then Localization::MONTHNAMES[lang][date.month]
326
366
  when 'b' then Localization::ABBR_MONTHNAMES[lang][date.month]
327
- when 'c' then local_date_string(date, Localization::DATE_FMT[lang], lang)
367
+ when 'c' then local_date_string(date, Localization::TIME_FMT[lang], lang)
328
368
  when 'P' then Localization::MERIDIAN[lang][date.send(:hour) < 12 ? 0 : 1].downcase
329
369
  when 'p' then Localization::MERIDIAN[lang][date.send(:hour) < 12 ? 0 : 1]
330
370
  else '%' << a
@@ -6,7 +6,7 @@ module Jekyll
6
6
 
7
7
  MAJOR = 0
8
8
  MINOR = 1
9
- TINY = 6
9
+ TINY = 7
10
10
 
11
11
  class << self
12
12
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-localization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.1.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jens Wille
@@ -10,27 +9,25 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-05-24 00:00:00.000000000 Z
12
+ date: 2013-05-14 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: jekyll-rendering
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  description: Jekyll plugin that adds localization features to the rendering engine.
32
29
  email:
33
- - jens.wille@uni-koeln.de
30
+ - jens.wille@gmail.com
34
31
  - eilermann@lavabit.com
35
32
  executables: []
36
33
  extensions: []
@@ -43,10 +40,11 @@ files:
43
40
  - lib/jekyll/localization/version.rb
44
41
  - COPYING
45
42
  - ChangeLog
46
- - Rakefile
47
43
  - README
44
+ - Rakefile
48
45
  homepage: http://github.com/blackwinter/jekyll-localization
49
46
  licenses: []
47
+ metadata: {}
50
48
  post_install_message:
51
49
  rdoc_options:
52
50
  - --charset
@@ -54,27 +52,25 @@ rdoc_options:
54
52
  - --line-numbers
55
53
  - --all
56
54
  - --title
57
- - jekyll-localization Application documentation (v0.1.6)
55
+ - jekyll-localization Application documentation (v0.1.7)
58
56
  - --main
59
57
  - README
60
58
  require_paths:
61
59
  - lib
62
60
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
61
  requirements:
65
- - - ! '>='
62
+ - - '>='
66
63
  - !ruby/object:Gem::Version
67
64
  version: '0'
68
65
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
66
  requirements:
71
- - - ! '>='
67
+ - - '>='
72
68
  - !ruby/object:Gem::Version
73
69
  version: '0'
74
70
  requirements: []
75
71
  rubyforge_project:
76
- rubygems_version: 1.8.24
72
+ rubygems_version: 2.0.3
77
73
  signing_key:
78
- specification_version: 3
74
+ specification_version: 4
79
75
  summary: Jekyll plugin that adds localization features to the rendering engine.
80
76
  test_files: []