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.
- data/bin/irb.rc +1 -0
- data/bin/locales.rb +8 -6
- data/bin/when.rb +1 -1
- data/lib/when_exe.rb +231 -146
- data/lib/when_exe/basictypes.rb +108 -18
- data/lib/when_exe/calendarnote.rb +263 -116
- data/lib/when_exe/calendartypes.rb +413 -22
- data/lib/when_exe/coordinates.rb +58 -36
- data/lib/when_exe/core/compatibility.rb +8 -6
- data/lib/when_exe/core/extension.rb +40 -15
- data/lib/when_exe/ephemeris.rb +20 -19
- data/lib/when_exe/{region → ephemeris}/moon.rb +4 -4
- data/lib/when_exe/{region/ephemeric_notes.rb → ephemeris/notes.rb} +25 -6
- data/lib/when_exe/{region → ephemeris}/planets.rb +0 -0
- data/lib/when_exe/{region → ephemeris}/sun.rb +7 -3
- data/lib/when_exe/{region → ephemeris}/v50.rb +0 -0
- data/lib/when_exe/googlecalendar.rb +2 -2
- data/lib/when_exe/icalendar.rb +3 -3
- data/lib/when_exe/inspect.rb +130 -70
- data/lib/when_exe/locales/af.rb +2 -2
- data/lib/when_exe/locales/akt.rb +176 -0
- data/lib/when_exe/locales/ar.rb +2 -2
- data/lib/when_exe/locales/{locales.rb → autoload.rb} +6 -2
- data/lib/when_exe/locales/az.rb +2 -2
- data/lib/when_exe/locales/bg.rb +2 -2
- data/lib/when_exe/locales/bn.rb +2 -2
- data/lib/when_exe/locales/bs.rb +2 -2
- data/lib/when_exe/locales/ca.rb +2 -2
- data/lib/when_exe/locales/cs.rb +2 -2
- data/lib/when_exe/locales/cy.rb +2 -2
- data/lib/when_exe/locales/da.rb +2 -2
- data/lib/when_exe/locales/de.rb +2 -2
- data/lib/when_exe/locales/de_AT.rb +2 -2
- data/lib/when_exe/locales/de_CH.rb +2 -2
- data/lib/when_exe/locales/el.rb +2 -2
- data/lib/when_exe/locales/en.rb +2 -2
- data/lib/when_exe/locales/en_AU.rb +2 -2
- data/lib/when_exe/locales/en_CA.rb +2 -2
- data/lib/when_exe/locales/en_GB.rb +2 -2
- data/lib/when_exe/locales/en_IE.rb +2 -2
- data/lib/when_exe/locales/en_IN.rb +3 -3
- data/lib/when_exe/locales/en_NZ.rb +2 -2
- data/lib/when_exe/locales/en_US.rb +2 -2
- data/lib/when_exe/locales/en_ZA.rb +88 -0
- data/lib/when_exe/locales/encoding_conversion.rb +126 -0
- data/lib/when_exe/locales/eo.rb +2 -2
- data/lib/when_exe/locales/es.rb +2 -2
- data/lib/when_exe/locales/es_419.rb +2 -2
- data/lib/when_exe/locales/es_AR.rb +2 -2
- data/lib/when_exe/locales/es_CL.rb +2 -2
- data/lib/when_exe/locales/es_CO.rb +2 -2
- data/lib/when_exe/locales/es_CR.rb +2 -2
- data/lib/when_exe/locales/es_EC.rb +2 -2
- data/lib/when_exe/locales/es_MX.rb +2 -2
- data/lib/when_exe/locales/es_PA.rb +2 -2
- data/lib/when_exe/locales/es_PE.rb +2 -2
- data/lib/when_exe/locales/es_US.rb +84 -0
- data/lib/when_exe/locales/es_VE.rb +2 -2
- data/lib/when_exe/locales/et.rb +2 -2
- data/lib/when_exe/locales/eu.rb +2 -2
- data/lib/when_exe/locales/fa.rb +2 -2
- data/lib/when_exe/locales/fi.rb +3 -3
- data/lib/when_exe/locales/fr.rb +2 -2
- data/lib/when_exe/locales/fr_CA.rb +2 -2
- data/lib/when_exe/locales/fr_CH.rb +2 -2
- data/lib/when_exe/locales/gl.rb +2 -2
- data/lib/when_exe/locales/he.rb +3 -3
- data/lib/when_exe/locales/hi.rb +2 -2
- data/lib/when_exe/locales/hi_IN.rb +2 -2
- data/lib/when_exe/locales/hr.rb +2 -2
- data/lib/when_exe/locales/hu.rb +6 -5
- data/lib/when_exe/locales/iast.rb +90 -0
- data/lib/when_exe/locales/id.rb +2 -2
- data/lib/when_exe/locales/is.rb +2 -2
- data/lib/when_exe/locales/it.rb +2 -2
- data/lib/when_exe/locales/it_CH.rb +2 -2
- data/lib/when_exe/locales/ja.rb +2 -2
- data/lib/when_exe/locales/kn.rb +2 -2
- data/lib/when_exe/locales/ko.rb +2 -2
- data/lib/when_exe/locales/links.rb +3 -3
- data/lib/when_exe/locales/lo.rb +2 -2
- data/lib/when_exe/{parts → locales}/locale.rb +77 -49
- data/lib/when_exe/locales/lt.rb +6 -2
- data/lib/when_exe/locales/lv.rb +2 -2
- data/lib/when_exe/locales/mk.rb +2 -2
- data/lib/when_exe/locales/mn.rb +2 -2
- data/lib/when_exe/locales/ms.rb +2 -2
- data/lib/when_exe/locales/nb.rb +2 -2
- data/lib/when_exe/locales/ne.rb +2 -2
- data/lib/when_exe/locales/nl.rb +2 -2
- data/lib/when_exe/locales/nn.rb +2 -2
- data/lib/when_exe/locales/or.rb +2 -2
- data/lib/when_exe/locales/pl.rb +2 -2
- data/lib/when_exe/locales/pt.rb +2 -2
- data/lib/when_exe/locales/pt_BR.rb +2 -2
- data/lib/when_exe/locales/rm.rb +2 -2
- data/lib/when_exe/locales/ro.rb +2 -2
- data/lib/when_exe/locales/ru.rb +2 -2
- data/lib/when_exe/locales/sk.rb +2 -2
- data/lib/when_exe/locales/sl.rb +2 -2
- data/lib/when_exe/locales/sr.rb +2 -2
- data/lib/when_exe/locales/sv.rb +2 -2
- data/lib/when_exe/locales/sw.rb +2 -2
- data/lib/when_exe/locales/ta.rb +95 -0
- data/lib/when_exe/locales/th.rb +2 -2
- data/lib/when_exe/locales/tl.rb +3 -3
- data/lib/when_exe/locales/tr.rb +2 -2
- data/lib/when_exe/locales/transliteration_table.rb +62 -0
- data/lib/when_exe/locales/uk.rb +15 -15
- data/lib/when_exe/locales/ur.rb +2 -2
- data/lib/when_exe/locales/uz.rb +2 -2
- data/lib/when_exe/locales/vi.rb +2 -2
- data/lib/when_exe/locales/wo.rb +2 -2
- data/lib/when_exe/locales/zh_CN.rb +2 -2
- data/lib/when_exe/locales/zh_HK.rb +15 -15
- data/lib/when_exe/locales/zh_TW.rb +2 -2
- data/lib/when_exe/locales/zh_YUE.rb +77 -0
- data/lib/when_exe/mini_application.rb +22 -12
- data/lib/when_exe/parts/geometric_complex.rb +16 -1
- data/lib/when_exe/parts/method_cash.rb +184 -238
- data/lib/when_exe/parts/resource.rb +65 -16
- data/lib/when_exe/region/armenian.rb +56 -0
- data/lib/when_exe/region/bahai.rb +13 -13
- data/lib/when_exe/region/balinese.rb +33 -35
- data/lib/when_exe/region/chinese.rb +82 -78
- data/lib/when_exe/region/{chinese_calendar.rb → chinese/calendars.rb} +59 -40
- data/lib/when_exe/region/{chinese_epoch.rb → chinese/epochs.rb} +3 -4
- data/lib/when_exe/region/{chinese_twin.rb → chinese/twins.rb} +48 -51
- data/lib/when_exe/region/christian.rb +236 -127
- data/lib/when_exe/region/coptic.rb +9 -10
- data/lib/when_exe/region/dee.rb +48 -0
- data/lib/when_exe/region/discordian.rb +225 -0
- data/lib/when_exe/region/far_east.rb +2 -6
- data/lib/when_exe/region/french.rb +7 -17
- data/lib/when_exe/region/geologicalage.rb +0 -1
- data/lib/when_exe/region/goddess.rb +58 -0
- data/lib/when_exe/region/indian.rb +323 -231
- data/lib/when_exe/region/iranian.rb +159 -22
- data/lib/when_exe/region/islamic.rb +7 -9
- data/lib/when_exe/region/japanese.rb +14 -803
- data/lib/when_exe/region/japanese/calendars.rb +397 -0
- data/lib/when_exe/region/japanese/epochs.rb +426 -0
- data/lib/when_exe/region/{nihon_shoki.rb → japanese/nihon_shoki.rb} +0 -2
- data/lib/when_exe/region/{japanese_notes.rb → japanese/notes.rb} +179 -150
- data/lib/when_exe/region/japanese/residues.rb +1306 -0
- data/lib/when_exe/region/{japanese_twin.rb → japanese/twins.rb} +12 -15
- data/lib/when_exe/region/javanese.rb +16 -14
- data/lib/when_exe/region/jewish.rb +8 -9
- data/lib/when_exe/region/korean.rb +146 -35
- data/lib/when_exe/region/m17n.rb +8 -10
- data/lib/when_exe/region/martian.rb +44 -16
- data/lib/when_exe/region/mayan.rb +12 -10
- data/lib/when_exe/region/pope.rb +0 -1
- data/lib/when_exe/region/residue.rb +4 -5
- data/lib/when_exe/region/roman.rb +20 -24
- data/lib/when_exe/region/ryukyu.rb +3 -4
- data/lib/when_exe/region/shire.rb +97 -94
- data/lib/when_exe/region/symmetry.rb +50 -0
- data/lib/when_exe/region/thai.rb +164 -56
- data/lib/when_exe/region/tibetan.rb +86 -86
- data/lib/when_exe/region/vietnamese.rb +9 -12
- data/lib/when_exe/region/weekdate.rb +80 -0
- data/lib/when_exe/region/world.rb +65 -70
- data/lib/when_exe/region/yerm.rb +98 -0
- data/lib/when_exe/region/zoroastrian.rb +203 -0
- data/lib/when_exe/timestandard.rb +4 -4
- data/lib/when_exe/tmobjects.rb +1 -3
- data/lib/when_exe/tmposition.rb +13 -12
- data/lib/when_exe/tmreference.rb +11 -10
- data/lib/when_exe/version.rb +1 -1
- data/link_to_online_documents +3 -3
- data/test/examples/Residue.m17n +1 -1
- data/test/examples/Terms.m17n +1 -1
- data/test/test.rb +2 -1
- data/test/test/basictypes.rb +18 -2
- data/test/test/calendarnote.rb +1 -1
- data/test/test/calendartypes.rb +1 -1
- data/test/test/coordinates.rb +7 -7
- data/test/test/{region → ephemeris}/moon.rb +0 -0
- data/test/test/{region → ephemeris}/planets.rb +0 -0
- data/test/test/{region → ephemeris}/sun.rb +0 -0
- data/test/test/parts.rb +8 -13
- data/test/test/region/christian.rb +245 -0
- data/test/test/region/french.rb +16 -16
- data/test/test/region/iran.rb +34 -34
- data/test/test/region/japanese.rb +6 -4
- data/test/test/region/m17n.rb +8 -7
- data/test/test/region/mayan.rb +12 -12
- data/test/test/region/residue.rb +20 -4
- data/test/test/region/thai.rb +25 -3
- data/test/test/region/yerm.rb +146 -0
- metadata +39 -20
- data/lib/when_exe/region/japanese_residues.rb +0 -1212
- data/test/test/region/civil.rb +0 -124
data/lib/when_exe/locales/id.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/is.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/it.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/ja.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/kn.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/ko.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
9
|
-
|
8
|
+
module When
|
9
|
+
module Locale
|
10
10
|
|
11
11
|
WikipediaLinks =
|
12
12
|
{"ja"=>
|
data/lib/when_exe/locales/lo.rb
CHANGED
@@ -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
|
9
|
-
|
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::
|
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::
|
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::
|
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::
|
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,
|
239
|
-
locale = locale.sub(/\..*/, '')
|
240
|
-
return hash[locale] if
|
241
|
-
return _hash_value(hash, _alias[locale],
|
242
|
-
language = locale.sub(
|
243
|
-
return hash[language] if
|
244
|
-
|
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
|
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::
|
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::
|
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::
|
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,
|
651
|
+
label = Locale._hash_value(@names, locale, [])
|
634
652
|
return label if label
|
635
|
-
foreign =
|
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!(/^#{
|
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
|
682
|
-
prefix = namespace[$1]
|
683
|
-
ref.sub!(/^.+:/, prefix) if
|
700
|
+
if ref =~ /^(.+):/
|
701
|
+
prefix = namespace[$1] || Locale.send(:_namespaces)[$1]
|
702
|
+
ref.sub!(/^.+:/, prefix) if prefix
|
684
703
|
end
|
685
|
-
ref += '%%<' + name + '>' if
|
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|
|
data/lib/when_exe/locales/lt.rb
CHANGED
@@ -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
|
9
|
-
|
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ė",
|
data/lib/when_exe/locales/lv.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/mk.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/mn.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/ms.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|
data/lib/when_exe/locales/nb.rb
CHANGED
@@ -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
|
9
|
-
|
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
|
|