when_exe 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/bin/irb.rc +1 -0
  2. data/bin/locales.rb +8 -6
  3. data/bin/when.rb +1 -1
  4. data/lib/when_exe.rb +231 -146
  5. data/lib/when_exe/basictypes.rb +108 -18
  6. data/lib/when_exe/calendarnote.rb +263 -116
  7. data/lib/when_exe/calendartypes.rb +413 -22
  8. data/lib/when_exe/coordinates.rb +58 -36
  9. data/lib/when_exe/core/compatibility.rb +8 -6
  10. data/lib/when_exe/core/extension.rb +40 -15
  11. data/lib/when_exe/ephemeris.rb +20 -19
  12. data/lib/when_exe/{region → ephemeris}/moon.rb +4 -4
  13. data/lib/when_exe/{region/ephemeric_notes.rb → ephemeris/notes.rb} +25 -6
  14. data/lib/when_exe/{region → ephemeris}/planets.rb +0 -0
  15. data/lib/when_exe/{region → ephemeris}/sun.rb +7 -3
  16. data/lib/when_exe/{region → ephemeris}/v50.rb +0 -0
  17. data/lib/when_exe/googlecalendar.rb +2 -2
  18. data/lib/when_exe/icalendar.rb +3 -3
  19. data/lib/when_exe/inspect.rb +130 -70
  20. data/lib/when_exe/locales/af.rb +2 -2
  21. data/lib/when_exe/locales/akt.rb +176 -0
  22. data/lib/when_exe/locales/ar.rb +2 -2
  23. data/lib/when_exe/locales/{locales.rb → autoload.rb} +6 -2
  24. data/lib/when_exe/locales/az.rb +2 -2
  25. data/lib/when_exe/locales/bg.rb +2 -2
  26. data/lib/when_exe/locales/bn.rb +2 -2
  27. data/lib/when_exe/locales/bs.rb +2 -2
  28. data/lib/when_exe/locales/ca.rb +2 -2
  29. data/lib/when_exe/locales/cs.rb +2 -2
  30. data/lib/when_exe/locales/cy.rb +2 -2
  31. data/lib/when_exe/locales/da.rb +2 -2
  32. data/lib/when_exe/locales/de.rb +2 -2
  33. data/lib/when_exe/locales/de_AT.rb +2 -2
  34. data/lib/when_exe/locales/de_CH.rb +2 -2
  35. data/lib/when_exe/locales/el.rb +2 -2
  36. data/lib/when_exe/locales/en.rb +2 -2
  37. data/lib/when_exe/locales/en_AU.rb +2 -2
  38. data/lib/when_exe/locales/en_CA.rb +2 -2
  39. data/lib/when_exe/locales/en_GB.rb +2 -2
  40. data/lib/when_exe/locales/en_IE.rb +2 -2
  41. data/lib/when_exe/locales/en_IN.rb +3 -3
  42. data/lib/when_exe/locales/en_NZ.rb +2 -2
  43. data/lib/when_exe/locales/en_US.rb +2 -2
  44. data/lib/when_exe/locales/en_ZA.rb +88 -0
  45. data/lib/when_exe/locales/encoding_conversion.rb +126 -0
  46. data/lib/when_exe/locales/eo.rb +2 -2
  47. data/lib/when_exe/locales/es.rb +2 -2
  48. data/lib/when_exe/locales/es_419.rb +2 -2
  49. data/lib/when_exe/locales/es_AR.rb +2 -2
  50. data/lib/when_exe/locales/es_CL.rb +2 -2
  51. data/lib/when_exe/locales/es_CO.rb +2 -2
  52. data/lib/when_exe/locales/es_CR.rb +2 -2
  53. data/lib/when_exe/locales/es_EC.rb +2 -2
  54. data/lib/when_exe/locales/es_MX.rb +2 -2
  55. data/lib/when_exe/locales/es_PA.rb +2 -2
  56. data/lib/when_exe/locales/es_PE.rb +2 -2
  57. data/lib/when_exe/locales/es_US.rb +84 -0
  58. data/lib/when_exe/locales/es_VE.rb +2 -2
  59. data/lib/when_exe/locales/et.rb +2 -2
  60. data/lib/when_exe/locales/eu.rb +2 -2
  61. data/lib/when_exe/locales/fa.rb +2 -2
  62. data/lib/when_exe/locales/fi.rb +3 -3
  63. data/lib/when_exe/locales/fr.rb +2 -2
  64. data/lib/when_exe/locales/fr_CA.rb +2 -2
  65. data/lib/when_exe/locales/fr_CH.rb +2 -2
  66. data/lib/when_exe/locales/gl.rb +2 -2
  67. data/lib/when_exe/locales/he.rb +3 -3
  68. data/lib/when_exe/locales/hi.rb +2 -2
  69. data/lib/when_exe/locales/hi_IN.rb +2 -2
  70. data/lib/when_exe/locales/hr.rb +2 -2
  71. data/lib/when_exe/locales/hu.rb +6 -5
  72. data/lib/when_exe/locales/iast.rb +90 -0
  73. data/lib/when_exe/locales/id.rb +2 -2
  74. data/lib/when_exe/locales/is.rb +2 -2
  75. data/lib/when_exe/locales/it.rb +2 -2
  76. data/lib/when_exe/locales/it_CH.rb +2 -2
  77. data/lib/when_exe/locales/ja.rb +2 -2
  78. data/lib/when_exe/locales/kn.rb +2 -2
  79. data/lib/when_exe/locales/ko.rb +2 -2
  80. data/lib/when_exe/locales/links.rb +3 -3
  81. data/lib/when_exe/locales/lo.rb +2 -2
  82. data/lib/when_exe/{parts → locales}/locale.rb +77 -49
  83. data/lib/when_exe/locales/lt.rb +6 -2
  84. data/lib/when_exe/locales/lv.rb +2 -2
  85. data/lib/when_exe/locales/mk.rb +2 -2
  86. data/lib/when_exe/locales/mn.rb +2 -2
  87. data/lib/when_exe/locales/ms.rb +2 -2
  88. data/lib/when_exe/locales/nb.rb +2 -2
  89. data/lib/when_exe/locales/ne.rb +2 -2
  90. data/lib/when_exe/locales/nl.rb +2 -2
  91. data/lib/when_exe/locales/nn.rb +2 -2
  92. data/lib/when_exe/locales/or.rb +2 -2
  93. data/lib/when_exe/locales/pl.rb +2 -2
  94. data/lib/when_exe/locales/pt.rb +2 -2
  95. data/lib/when_exe/locales/pt_BR.rb +2 -2
  96. data/lib/when_exe/locales/rm.rb +2 -2
  97. data/lib/when_exe/locales/ro.rb +2 -2
  98. data/lib/when_exe/locales/ru.rb +2 -2
  99. data/lib/when_exe/locales/sk.rb +2 -2
  100. data/lib/when_exe/locales/sl.rb +2 -2
  101. data/lib/when_exe/locales/sr.rb +2 -2
  102. data/lib/when_exe/locales/sv.rb +2 -2
  103. data/lib/when_exe/locales/sw.rb +2 -2
  104. data/lib/when_exe/locales/ta.rb +95 -0
  105. data/lib/when_exe/locales/th.rb +2 -2
  106. data/lib/when_exe/locales/tl.rb +3 -3
  107. data/lib/when_exe/locales/tr.rb +2 -2
  108. data/lib/when_exe/locales/transliteration_table.rb +62 -0
  109. data/lib/when_exe/locales/uk.rb +15 -15
  110. data/lib/when_exe/locales/ur.rb +2 -2
  111. data/lib/when_exe/locales/uz.rb +2 -2
  112. data/lib/when_exe/locales/vi.rb +2 -2
  113. data/lib/when_exe/locales/wo.rb +2 -2
  114. data/lib/when_exe/locales/zh_CN.rb +2 -2
  115. data/lib/when_exe/locales/zh_HK.rb +15 -15
  116. data/lib/when_exe/locales/zh_TW.rb +2 -2
  117. data/lib/when_exe/locales/zh_YUE.rb +77 -0
  118. data/lib/when_exe/mini_application.rb +22 -12
  119. data/lib/when_exe/parts/geometric_complex.rb +16 -1
  120. data/lib/when_exe/parts/method_cash.rb +184 -238
  121. data/lib/when_exe/parts/resource.rb +65 -16
  122. data/lib/when_exe/region/armenian.rb +56 -0
  123. data/lib/when_exe/region/bahai.rb +13 -13
  124. data/lib/when_exe/region/balinese.rb +33 -35
  125. data/lib/when_exe/region/chinese.rb +82 -78
  126. data/lib/when_exe/region/{chinese_calendar.rb → chinese/calendars.rb} +59 -40
  127. data/lib/when_exe/region/{chinese_epoch.rb → chinese/epochs.rb} +3 -4
  128. data/lib/when_exe/region/{chinese_twin.rb → chinese/twins.rb} +48 -51
  129. data/lib/when_exe/region/christian.rb +236 -127
  130. data/lib/when_exe/region/coptic.rb +9 -10
  131. data/lib/when_exe/region/dee.rb +48 -0
  132. data/lib/when_exe/region/discordian.rb +225 -0
  133. data/lib/when_exe/region/far_east.rb +2 -6
  134. data/lib/when_exe/region/french.rb +7 -17
  135. data/lib/when_exe/region/geologicalage.rb +0 -1
  136. data/lib/when_exe/region/goddess.rb +58 -0
  137. data/lib/when_exe/region/indian.rb +323 -231
  138. data/lib/when_exe/region/iranian.rb +159 -22
  139. data/lib/when_exe/region/islamic.rb +7 -9
  140. data/lib/when_exe/region/japanese.rb +14 -803
  141. data/lib/when_exe/region/japanese/calendars.rb +397 -0
  142. data/lib/when_exe/region/japanese/epochs.rb +426 -0
  143. data/lib/when_exe/region/{nihon_shoki.rb → japanese/nihon_shoki.rb} +0 -2
  144. data/lib/when_exe/region/{japanese_notes.rb → japanese/notes.rb} +179 -150
  145. data/lib/when_exe/region/japanese/residues.rb +1306 -0
  146. data/lib/when_exe/region/{japanese_twin.rb → japanese/twins.rb} +12 -15
  147. data/lib/when_exe/region/javanese.rb +16 -14
  148. data/lib/when_exe/region/jewish.rb +8 -9
  149. data/lib/when_exe/region/korean.rb +146 -35
  150. data/lib/when_exe/region/m17n.rb +8 -10
  151. data/lib/when_exe/region/martian.rb +44 -16
  152. data/lib/when_exe/region/mayan.rb +12 -10
  153. data/lib/when_exe/region/pope.rb +0 -1
  154. data/lib/when_exe/region/residue.rb +4 -5
  155. data/lib/when_exe/region/roman.rb +20 -24
  156. data/lib/when_exe/region/ryukyu.rb +3 -4
  157. data/lib/when_exe/region/shire.rb +97 -94
  158. data/lib/when_exe/region/symmetry.rb +50 -0
  159. data/lib/when_exe/region/thai.rb +164 -56
  160. data/lib/when_exe/region/tibetan.rb +86 -86
  161. data/lib/when_exe/region/vietnamese.rb +9 -12
  162. data/lib/when_exe/region/weekdate.rb +80 -0
  163. data/lib/when_exe/region/world.rb +65 -70
  164. data/lib/when_exe/region/yerm.rb +98 -0
  165. data/lib/when_exe/region/zoroastrian.rb +203 -0
  166. data/lib/when_exe/timestandard.rb +4 -4
  167. data/lib/when_exe/tmobjects.rb +1 -3
  168. data/lib/when_exe/tmposition.rb +13 -12
  169. data/lib/when_exe/tmreference.rb +11 -10
  170. data/lib/when_exe/version.rb +1 -1
  171. data/link_to_online_documents +3 -3
  172. data/test/examples/Residue.m17n +1 -1
  173. data/test/examples/Terms.m17n +1 -1
  174. data/test/test.rb +2 -1
  175. data/test/test/basictypes.rb +18 -2
  176. data/test/test/calendarnote.rb +1 -1
  177. data/test/test/calendartypes.rb +1 -1
  178. data/test/test/coordinates.rb +7 -7
  179. data/test/test/{region → ephemeris}/moon.rb +0 -0
  180. data/test/test/{region → ephemeris}/planets.rb +0 -0
  181. data/test/test/{region → ephemeris}/sun.rb +0 -0
  182. data/test/test/parts.rb +8 -13
  183. data/test/test/region/christian.rb +245 -0
  184. data/test/test/region/french.rb +16 -16
  185. data/test/test/region/iran.rb +34 -34
  186. data/test/test/region/japanese.rb +6 -4
  187. data/test/test/region/m17n.rb +8 -7
  188. data/test/test/region/mayan.rb +12 -12
  189. data/test/test/region/residue.rb +20 -4
  190. data/test/test/region/thai.rb +25 -3
  191. data/test/test/region/yerm.rb +146 -0
  192. metadata +39 -20
  193. data/lib/when_exe/region/japanese_residues.rb +0 -1212
  194. data/test/test/region/civil.rb +0 -124
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/id.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/is.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/it.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/it-CH.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/kn.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/ko.yml
12
12
 
@@ -1,12 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2013 Takashi SUGA
3
+ Copyright (C) 2013-2014 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  WikipediaLinks =
12
12
  {"ja"=>
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/lo.yml
12
12
 
@@ -5,10 +5,9 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- #
9
- # 本ライブラリのための諸々の部品
10
- #
11
- module When::Parts
8
+ require 'when_exe/locales/encoding_conversion'
9
+
10
+ module When
12
11
 
13
12
  #
14
13
  # Multilingualization(M17n) 対応モジュール
@@ -21,28 +20,23 @@ module When::Parts
21
20
  # Locale 読み替えの初期設定
22
21
  DefaultAlias = {'alias'=>'ja', '日本語'=>'ja', '英語'=>'en'}
23
22
 
23
+ # 省略時 Namespace
24
+ DefaultNamespaces = Hash.new {|hash, key|
25
+ hash[key] = "http://#{key}.wikipedia.org/wiki/"
26
+ }.update({
27
+ 'mailto' => false,
28
+ 'https' => false,
29
+ 'http' => false,
30
+ 'ftp' => false
31
+ })
32
+
24
33
  # 漢字の包摂
25
34
  DefaultUnification = {
26
- '煕' => '',
27
- '' => '',
28
- '' => '',
29
- '' => '',
30
- '' => '',
31
- '觀' => '観',
32
- '龜' => '亀',
33
- '齊' => '斉',
34
- '靈' => '霊',
35
- '攝' => '摂',
36
- '壽' => '寿',
37
- '萬' => '万',
38
- '廢' => '廃',
39
- '顯' => '顕',
40
- '會' => '会',
41
- '聰' => '聡',
42
- '總' => '総',
43
- '證' => '証',
44
- '禮' => '礼',
45
- '竜' => '龍',
35
+ '煕'=>'熙', '廣'=>'広', ''=>'宝', '國'=>'国',
36
+ ''=>'応', '觀'=>'観', ''=>'亀', '齊'=>'斉',
37
+ ''=>'霊', '攝'=>'摂', ''=>'寿', '萬'=>'万',
38
+ ''=>'廃', '顯'=>'顕', ''=>'会', '聰'=>'聡',
39
+ ''=>'総', '證'=>'証', ''=>'礼', '竜'=>'龍'
46
40
  }
47
41
 
48
42
  # Escape
@@ -70,10 +64,11 @@ module When::Parts
70
64
  #
71
65
  attr_accessor :wikipedia_interval
72
66
 
73
- # When::Parts::Locale Module のグローバルな設定を行う
67
+ # When::Locale Module のグローバルな設定を行う
74
68
  #
75
69
  # @param [Hash] options 下記の通り
76
70
  # @option options [Hash] :alias Locale の読み替えパターンを Hash で指定する。
71
+ # @option options [String] :namespaces 名前空間定義の省略時に名前空間生成に用いる書式
77
72
  # @option options [Hash] :unification 漢字の包摂パターンを Hash で指定する。
78
73
  # @option options [Numeric] :wikipedia_interval Wikipedia の連続的な参照を抑制するための遅延時間/秒
79
74
  #
@@ -83,6 +78,7 @@ module When::Parts
83
78
  #
84
79
  def _setup_(options={})
85
80
  @aliases = options[:alias] || DefaultAlias
81
+ @namespaces = options[:namespaces] || DefaultNamespaces
86
82
  @unifications = options[:unification] || DefaultUnification
87
83
  @wikipedia_interval = options[:wikipedia_interval]
88
84
  end
@@ -93,6 +89,7 @@ module When::Parts
93
89
  #
94
90
  def _setup_info
95
91
  {:alias => _alias,
92
+ :namespaces => _namespaces,
96
93
  :unification => _unification,
97
94
  :wikipedia_interval => @wikipedia_interval}
98
95
  end
@@ -132,18 +129,18 @@ module When::Parts
132
129
 
133
130
  # 包摂リストに登録されている文字を包摂する
134
131
  #
135
- # @param [When::Parts::Locale] source 文字を包摂しようとする国際化文字列
132
+ # @param [When::Locale] source 文字を包摂しようとする国際化文字列
136
133
  # @param [String] source 文字を包摂しようとする文字列
137
134
  # @param [Regexp] source 文字を包摂しようとする正規表現
138
135
  # @param [Hash] pattern 包摂ルール
139
136
  #
140
- # @return [When::Parts::Locale] 文字を包摂した国際化文字列
137
+ # @return [When::Locale] 文字を包摂した国際化文字列
141
138
  # @return [String] 文字を包摂した文字列
142
139
  # @return [Regexp] 文字を包摂した正規表現
143
140
  #
144
141
  def ideographic_unification(source, pattern=_unification)
145
142
  case source
146
- when When::Parts::Locale
143
+ when When::Locale
147
144
  source.ideographic_unification(pattern)
148
145
  when Regexp
149
146
  Regexp.compile(ideographic_unification(source.source.encode('UTF-8'), pattern), source.options)
@@ -235,13 +232,16 @@ module When::Parts
235
232
 
236
233
  # locale 指定を解析して Hash の値を取り出す
237
234
  # @private
238
- def _hash_value(hash, locale, default='')
239
- locale = locale.sub(/\..*/, '').sub(/-/,'_')
240
- return hash[locale] if (hash[locale])
241
- return _hash_value(hash, _alias[locale], default) if _alias[locale]
242
- language = locale.sub(/_.*/, '')
243
- return hash[language] if (hash[language])
244
- return hash[default]
235
+ def _hash_value(hash, locale, defaults=['', 'en'])
236
+ locale = locale.sub(/\..*/, '')
237
+ return hash[locale] if hash[locale]
238
+ return _hash_value(hash, _alias[locale], defaults) if _alias[locale]
239
+ language = locale.sub(/-.*/, '')
240
+ return hash[language] if hash[language]
241
+ defaults.each do |default|
242
+ return hash[default] if hash[default]
243
+ end
244
+ return nil
245
245
  end
246
246
 
247
247
  # 漢字の包摂パターン
@@ -250,11 +250,28 @@ module When::Parts
250
250
  @unifications ||= DefaultUnification
251
251
  end
252
252
 
253
+ # @private
254
+ def _get_locale(locale, access_key)
255
+ return nil unless access_key
256
+ access_key = access_key.split(/\//).map {|key| key =~ /^[0-9]+$/ ? key.to_i : key}
257
+ locale = locale.sub(/\..*/, '')
258
+ [locale, locale.sub(/-.*/, '')].each do |loc|
259
+ symbol = ('Locale_' + loc.sub(/-/,'_')).to_sym
260
+ return {loc=>access_key.inject(const_get(symbol)) {|hash, key| hash = hash[key]}} if const_defined?(symbol)
261
+ end
262
+ return nil
263
+ end
264
+
253
265
  private
254
266
 
255
267
  # Locale の読み替えパターン
256
268
  def _alias
257
- @aliases ||= DefaultAlias
269
+ @aliases ||= DefaultAlias
270
+ end
271
+
272
+ # 名前空間定義の省略時に名前空間生成に用いる書式
273
+ def _namespaces
274
+ @namespaces ||= DefaultNamespaces
258
275
  end
259
276
 
260
277
  # wikipedia オブジェクトの生成・参照
@@ -270,7 +287,7 @@ module When::Parts
270
287
  # 採取済みデータ
271
288
  title = URI.decode(file.gsub('_', ' '))
272
289
  mode = "".respond_to?(:force_encoding) ? ':utf-8' : ''
273
- dir = Resource.root_dir + '/data/wikipedia/' + locale
290
+ dir = When::Parts::Resource.root_dir + '/data/wikipedia/' + locale
274
291
  FileUtils.mkdir_p(dir) unless FileTest.exist?(dir)
275
292
 
276
293
  open("#{dir}/#{file}.json", 'r'+mode) do |source|
@@ -389,6 +406,7 @@ module When::Parts
389
406
  #
390
407
  def translate(loc='')
391
408
  return to_s unless loc
409
+ loc = loc.sub('_', '-')
392
410
  lang, code = loc.split(/\./)
393
411
  result = _label_value(loc)
394
412
  return result if !code || @names.member?(loc)
@@ -404,14 +422,14 @@ module When::Parts
404
422
  #
405
423
  def reference(loc='')
406
424
  loc ||= ''
407
- return Locale._hash_value(@link, loc)
425
+ return Locale._hash_value(@link, loc.sub('_', '-'))
408
426
  end
409
427
 
410
428
  # 部分文字列
411
429
  #
412
430
  # @param [Range] range String#[] と同様の指定方法で範囲を指定する
413
431
  #
414
- # @return [When::Parts::Locale] 指定範囲に対応した部分文字列
432
+ # @return [When::Locale] 指定範囲に対応した部分文字列
415
433
  #
416
434
  def [](range)
417
435
  dup._copy({
@@ -555,7 +573,7 @@ module When::Parts
555
573
  #
556
574
  # @param [Hash] pattern 包摂ルール
557
575
  #
558
- # @return [When::Parts::Locale] self
576
+ # @return [When::Locale] self
559
577
  # @private
560
578
  def ideographic_unification!(pattern=_unification)
561
579
  names = {}
@@ -573,7 +591,7 @@ module When::Parts
573
591
  #
574
592
  # @param [Hash] pattern 包摂ルール
575
593
  #
576
- # @return [When::Parts::Locale] 包摂結果
594
+ # @return [When::Locale] 包摂結果
577
595
  #
578
596
  def ideographic_unification(pattern=_unification)
579
597
  dup.ideographic_unification!(pattern)
@@ -630,12 +648,12 @@ module When::Parts
630
648
  # locale 指定を解析して @names の値を取り出す
631
649
  # @private
632
650
  def _label_value(locale)
633
- label = Locale._hash_value(@names, locale, nil)
651
+ label = Locale._hash_value(@names, locale, [])
634
652
  return label if label
635
- foreign = When::BasicTypes::M17n._get_locale(locale, @access_key)
653
+ foreign = Locale._get_locale(locale, @access_key)
636
654
  return @names[''] unless foreign
637
655
  english = @names['en'] || @names['']
638
- addition = english.dup.sub!(/^#{When::BasicTypes::M17n._get_locale('en', @access_key)['en']}/, '')
656
+ addition = english.dup.sub!(/^#{Locale._get_locale('en', @access_key)['en']}/, '')
639
657
  foreign[locale] += addition if addition
640
658
  update(foreign)
641
659
  return Locale._hash_value(@names, locale)
@@ -677,13 +695,14 @@ module When::Parts
677
695
  mark[0] = locale if asterisk[0]
678
696
  mark[1] = locale if asterisk[1]
679
697
  mark[2] = locale unless mark[2]
698
+ name = _replacement($1, locale, ($3 || @names['en'] || @names[''])) if name =~ /^_([A-Z_]+)_(\((.+)\))?$/
680
699
  @names[locale] = name
681
- if (ref =~ /^(.+):/)
682
- prefix = namespace[$1]
683
- ref.sub!(/^.+:/, prefix) if (prefix)
700
+ if ref =~ /^(.+):/
701
+ prefix = namespace[$1] || Locale.send(:_namespaces)[$1]
702
+ ref.sub!(/^.+:/, prefix) if prefix
684
703
  end
685
- ref += '%%<' + name + '>' if (ref =~ /[\/#:]$/)
686
- @link[locale] = _encode(ref)
704
+ ref += '%%<' + name + '>' if ref =~ /[\/#:]$/
705
+ @link[locale] = _encode(ref) unless ref == ''
687
706
  else ; raise ArgumentError, "Irregal locale format: " + v
688
707
  end
689
708
  end
@@ -708,6 +727,15 @@ module When::Parts
708
727
  @names[mark[0] || mark[1] || mark[2]]
709
728
  end
710
729
 
730
+ #
731
+ # 英語表記を現地表記に置き換える
732
+ #
733
+ def _replacement(table, locale, name)
734
+ Locale.const_get(table.split('_')[-1])[locale] ?
735
+ Locale.send(table.downcase, name, locale) :
736
+ name
737
+ end
738
+
711
739
  # encode URI from patterns %%(...) or %.(...)
712
740
  def _encode(source)
713
741
  source.gsub(/%.<.+?>/) do |match|
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/lt.yml
12
12
 
@@ -73,6 +73,10 @@ module When::BasicTypes
73
73
  {"one"=>"apie %{count} metus",
74
74
  "few"=>"apie %{count} metus",
75
75
  "other"=>"apie %{count} metų"},
76
+ "almost_x_years"=>
77
+ {"one"=>"beveik 1 metai",
78
+ "few"=>"beveik %{count} metai",
79
+ "other"=>"beveik %{count} metų"},
76
80
  "half_a_minute"=>"pusė minutės",
77
81
  "less_than_x_minutes"=>
78
82
  {"one"=>"mažiau nei %{count} minutė",
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/lv.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/mk.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/mn.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/ms.yml
12
12
 
@@ -5,8 +5,8 @@
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
7
7
 
8
- module When::BasicTypes
9
- class M17n
8
+ module When
9
+ module Locale
10
10
 
11
11
  # from https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/nb.yml
12
12