ruby-cldr-timezones 0.0.6 → 0.0.7
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/.travis.yml +1 -5
- data/Gemfile +2 -2
- data/Gemfile.lock +18 -18
- data/Readme.md +19 -7
- data/lib/cldr/timezones.rb +54 -11
- data/lib/cldr/timezones/vars.rb +129 -1
- data/lib/cldr/timezones/version.rb +1 -1
- data/ruby-cldr-timezones.gemspec +2 -1
- data/spec/cldr_timezones_spec.rb +52 -11
- metadata +4 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ruby-cldr-timezones (0.0.
|
|
4
|
+
ruby-cldr-timezones (0.0.7)
|
|
5
5
|
tzinfo
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
|
-
remote:
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
bump (0.
|
|
11
|
-
diff-lcs (1.
|
|
12
|
-
i18n (0.6.
|
|
13
|
-
nokogiri (1.5.
|
|
14
|
-
rake (10.0.
|
|
15
|
-
rspec (2.
|
|
16
|
-
rspec-core (~> 2.
|
|
17
|
-
rspec-expectations (~> 2.
|
|
18
|
-
rspec-mocks (~> 2.
|
|
19
|
-
rspec-core (2.
|
|
20
|
-
rspec-expectations (2.
|
|
21
|
-
diff-lcs (
|
|
22
|
-
rspec-mocks (2.
|
|
10
|
+
bump (0.4.2)
|
|
11
|
+
diff-lcs (1.2.4)
|
|
12
|
+
i18n (0.6.4)
|
|
13
|
+
nokogiri (1.5.9)
|
|
14
|
+
rake (10.0.4)
|
|
15
|
+
rspec (2.13.0)
|
|
16
|
+
rspec-core (~> 2.13.0)
|
|
17
|
+
rspec-expectations (~> 2.13.0)
|
|
18
|
+
rspec-mocks (~> 2.13.0)
|
|
19
|
+
rspec-core (2.13.1)
|
|
20
|
+
rspec-expectations (2.13.0)
|
|
21
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
22
|
+
rspec-mocks (2.13.1)
|
|
23
23
|
ruby-cldr (0.0.2)
|
|
24
24
|
i18n
|
|
25
25
|
nokogiri
|
|
26
26
|
thor
|
|
27
27
|
ya2yaml
|
|
28
|
-
thor (0.
|
|
29
|
-
tzinfo (0.3.
|
|
28
|
+
thor (0.18.1)
|
|
29
|
+
tzinfo (0.3.37)
|
|
30
30
|
ya2yaml (0.31)
|
|
31
31
|
|
|
32
32
|
PLATFORMS
|
|
@@ -38,4 +38,4 @@ DEPENDENCIES
|
|
|
38
38
|
rspec (~> 2)
|
|
39
39
|
ruby-cldr
|
|
40
40
|
ruby-cldr-timezones!
|
|
41
|
-
tzinfo
|
|
41
|
+
tzinfo (= 0.3.37)
|
data/Readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Translated timezones according to CLDR
|
|
2
2
|
|
|
3
3
|
Install
|
|
4
4
|
=======
|
|
@@ -16,25 +16,37 @@ To get a basic subset of translations you can simply pass the locale.
|
|
|
16
16
|
|
|
17
17
|
Cldr::Timezones.list(:es) # {"Europe/Moscow" => "(GMT+04:00) Moscú"}
|
|
18
18
|
Cldr::Timezones.list(:ja) # {"America/Cordoba" => "(GMT-09:00)モスクワ"}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
There is also support for fallback.
|
|
21
21
|
|
|
22
22
|
Cldr::Timezones.list(:"es-MX") # {"Europe/Moscow" => "(GMT+04:00) Moscú"}
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
If you want to retrieve the full set of timezones (currently 581) you can simply pass the option ```:full```
|
|
26
25
|
|
|
27
26
|
Cldr::Timezones.list(:ja, :full) #To get the full list of timezones
|
|
28
27
|
|
|
28
|
+
If you want to get a list which contains the translated name, offset and GMT translation and format for each translation (supports :full option, i.e. `:pt, :full`)
|
|
29
|
+
|
|
30
|
+
Cldr::Timezones.raw(:ja) # {"America/Cordoba" => ["コルドバ", "+08:00", "GMT"]
|
|
31
|
+
|
|
32
|
+
If you want to get the list of supported languages
|
|
33
|
+
|
|
34
|
+
Cldr::Timezones.supported_locales # ["aa", "aa-DJ", "aa-ER", "aa-ET",...."zh-Hant-TW", "zu", "zu-ZA"]
|
|
35
|
+
|
|
36
|
+
If your project is already using ActiveSupport mapping and you want backwards compatibility use:
|
|
37
|
+
|
|
38
|
+
Cldr::Timezones.list(:ja, :rails_identifiers) # {"St. Petersburg" => "(GMT+04:00) Moscú"}
|
|
39
|
+
|
|
40
|
+
If you want both ActiveSupport mapping and the full list of timezones use:
|
|
41
|
+
|
|
42
|
+
Cldr::Timezones.list(:ja, {:rails_identifiers => true, :full => true}) #To get the full list of timezones
|
|
43
|
+
|
|
29
44
|
|
|
30
45
|
TODO
|
|
31
46
|
====
|
|
32
47
|
- Handle BIDI timezones
|
|
33
48
|
|
|
34
49
|
```Cldr::Timezones.list(:ar) # {"America/Cordoba" => "0}جرينتش} كوردوبا"}```
|
|
35
|
-
- Handle method raw which will return translated name, offset and GMT translation and format
|
|
36
|
-
|
|
37
|
-
```Cldr::Timezones.raw(:ja) # {"America/Cordoba" => ["コルドバ", "+08:00", "GMT"]}```
|
|
38
50
|
|
|
39
51
|
Author
|
|
40
52
|
======
|
|
@@ -44,4 +56,4 @@ License: MIT<br/>
|
|
|
44
56
|
|
|
45
57
|
|
|
46
58
|
[](https://travis-ci.org/anamartinez/ruby-cldr-timezones)
|
|
47
|
-
[](https://codeclimate.com/github/anamartinez/ruby-cldr-timezones)
|
data/lib/cldr/timezones.rb
CHANGED
|
@@ -6,27 +6,51 @@ require "tzinfo"
|
|
|
6
6
|
module Cldr
|
|
7
7
|
module Timezones
|
|
8
8
|
class << self
|
|
9
|
-
|
|
9
|
+
#Returns a hash with the translated timezones for the locale specified.
|
|
10
|
+
def list(locale, options = {})
|
|
10
11
|
raise ArgumentError, "Locale cannot be blank" unless locale
|
|
11
|
-
build_list(locale.to_s,
|
|
12
|
+
build_list(locale.to_s, options)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
def raw(locale, options = {})
|
|
16
|
+
raise ArgumentError, "Locale cannot be blank" unless locale
|
|
17
|
+
build_raw_list(locale.to_s, options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#Returns an array with the supported locales.
|
|
16
21
|
def supported_locales
|
|
17
22
|
Dir[path_to_cached_locales].map { |path| path =~ /([\w-]+)\/timezones\.yml/ && $1 }
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
private
|
|
21
26
|
|
|
22
|
-
def build_list(locale,
|
|
27
|
+
def build_list(locale, options)
|
|
28
|
+
timezones_hash(locale, options) do |identifier, name, offset, system|
|
|
29
|
+
[ identifier, format_timezone(offset, name) ]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def build_raw_list(locale, options)
|
|
34
|
+
timezones_hash(locale, options) do |identifier, name, offset, system|
|
|
35
|
+
[ identifier, [ name, offset, system ] ]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def timezones_hash(locale, options)
|
|
40
|
+
options_hash(options)
|
|
23
41
|
timezones_translations = load_timezones_translations(locale)
|
|
24
42
|
fallback = fallback(locale)
|
|
25
|
-
timezones_identifiers = (all ? TZInfo::Timezone.all : SUBSET_TIMEZONES)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
timezone = TZInfo::Timezone.get(timezone) unless all
|
|
29
|
-
|
|
43
|
+
timezones_identifiers = (@all ? TZInfo::Timezone.all : SUBSET_TIMEZONES)
|
|
44
|
+
timezone_list = []
|
|
45
|
+
timezones_identifiers.each do |timezone|
|
|
46
|
+
timezone = TZInfo::Timezone.get(timezone) unless @all
|
|
47
|
+
name, offset, system = build_timezone(timezones_translations, fallback, timezone)
|
|
48
|
+
identifier_name = timezone_identifier_mapping(timezone.identifier)
|
|
49
|
+
if identifier_name.is_a? Array
|
|
50
|
+
identifier_name.each {|identifier| timezone_list << yield(identifier, name, offset, system)}
|
|
51
|
+
else
|
|
52
|
+
timezone_list << yield(identifier_name, name, offset, system)
|
|
53
|
+
end
|
|
30
54
|
end
|
|
31
55
|
Hash[timezone_list]
|
|
32
56
|
end
|
|
@@ -65,7 +89,7 @@ module Cldr
|
|
|
65
89
|
name = translation["city"]
|
|
66
90
|
end
|
|
67
91
|
|
|
68
|
-
|
|
92
|
+
[name, offset, 'GMT']
|
|
69
93
|
end
|
|
70
94
|
|
|
71
95
|
#TODO - Get i18n format
|
|
@@ -94,6 +118,25 @@ module Cldr
|
|
|
94
118
|
path = File.expand_path("../../cache/en/timezones.yml", File.dirname(__FILE__))
|
|
95
119
|
path.gsub("en/timezones.yml", "*/timezones.yml")
|
|
96
120
|
end
|
|
121
|
+
|
|
122
|
+
def options_hash(options)
|
|
123
|
+
if options.is_a? Symbol
|
|
124
|
+
case options
|
|
125
|
+
when :full
|
|
126
|
+
@all = true
|
|
127
|
+
when :rails_identifiers
|
|
128
|
+
@rails_identifiers = true
|
|
129
|
+
end
|
|
130
|
+
else
|
|
131
|
+
@all = options[:full]
|
|
132
|
+
@rails_identifiers = options[:rails_identifiers]
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def timezone_identifier_mapping(cldr_identifier)
|
|
137
|
+
return cldr_identifier unless @rails_identifiers
|
|
138
|
+
RAILS_IDENTIFIERS[cldr_identifier] || cldr_identifier
|
|
139
|
+
end
|
|
97
140
|
end
|
|
98
141
|
end
|
|
99
142
|
end
|
data/lib/cldr/timezones/vars.rb
CHANGED
|
@@ -132,4 +132,132 @@ Cldr::Timezones::UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
|
|
|
132
132
|
"Pacific/Auckland",
|
|
133
133
|
"Pacific/Auckland",
|
|
134
134
|
"Pacific/Tongatapu"
|
|
135
|
-
].freeze
|
|
135
|
+
].freeze
|
|
136
|
+
|
|
137
|
+
Cldr::Timezones::RAILS_IDENTIFIERS = {
|
|
138
|
+
"Pacific/Midway" => ["International Date Line West", "Midway Island"],
|
|
139
|
+
"Pacific/Pago_Pago" => "American Samoa",
|
|
140
|
+
"Pacific/Honolulu" => "Hawaii",
|
|
141
|
+
"America/Juneau" => "Alaska",
|
|
142
|
+
"America/Los_Angeles" => "Pacific Time (US & Canada)",
|
|
143
|
+
"America/Tijuana" => "Tijuana",
|
|
144
|
+
"America/Denver" => "Mountain Time (US & Canada)",
|
|
145
|
+
"America/Phoenix" => "Arizona",
|
|
146
|
+
"America/Chihuahua" => "Chihuahua",
|
|
147
|
+
"America/Mazatlan" => "Mazatlan",
|
|
148
|
+
"America/Chicago" => "Central Time (US & Canada)",
|
|
149
|
+
"America/Regina" => "Saskatchewan",
|
|
150
|
+
"America/Mexico_City" => ["Guadalajara", "Mexico City"],
|
|
151
|
+
"America/Monterrey" => "Monterrey",
|
|
152
|
+
"America/Guatemala" => "Central America",
|
|
153
|
+
"America/New_York" => "Eastern Time (US & Canada)",
|
|
154
|
+
"America/Indiana/Indianapolis" => "Indiana (East)",
|
|
155
|
+
"America/Bogota" => "Bogota",
|
|
156
|
+
"America/Lima" => ["Lima", "Quito"],
|
|
157
|
+
"America/Halifax" => "Atlantic Time (Canada)",
|
|
158
|
+
"America/Caracas" => "Caracas",
|
|
159
|
+
"America/La_Paz" => "La Paz",
|
|
160
|
+
"America/Santiago" => "Santiago",
|
|
161
|
+
"America/St_Johns" => "Newfoundland",
|
|
162
|
+
"America/Sao_Paulo" => "Brasilia",
|
|
163
|
+
"America/Argentina/Buenos_Aires" => "Buenos Aires",
|
|
164
|
+
"America/Guyana" => "Georgetown",
|
|
165
|
+
"America/Godthab" => "Greenland",
|
|
166
|
+
"Atlantic/South_Georgia" => "Mid-Atlantic",
|
|
167
|
+
"Atlantic/Azores" => "Azores",
|
|
168
|
+
"Atlantic/Cape_Verde" => "Cape Verde Is.",
|
|
169
|
+
"Europe/Dublin" => "Dublin",
|
|
170
|
+
"Europe/London" => ["Edinburgh", "London"],
|
|
171
|
+
"Europe/Lisbon" => "Lisbon",
|
|
172
|
+
"Africa/Casablanca" => "Casablanca",
|
|
173
|
+
"Africa/Monrovia" => "Monrovia",
|
|
174
|
+
"Etc/UTC" => "UTC",
|
|
175
|
+
"Europe/Belgrade" => "Belgrade",
|
|
176
|
+
"Europe/Bratislava" => "Bratislava",
|
|
177
|
+
"Europe/Budapest" => "Budapest",
|
|
178
|
+
"Europe/Ljubljana" => "Ljubljana",
|
|
179
|
+
"Europe/Prague" => "Prague",
|
|
180
|
+
"Europe/Sarajevo" => "Sarajevo",
|
|
181
|
+
"Europe/Skopje" => "Skopje",
|
|
182
|
+
"Europe/Warsaw" => "Warsaw",
|
|
183
|
+
"Europe/Zagreb" => "Zagreb",
|
|
184
|
+
"Europe/Brussels" => "Brussels",
|
|
185
|
+
"Europe/Copenhagen" => "Copenhagen",
|
|
186
|
+
"Europe/Madrid" => "Madrid",
|
|
187
|
+
"Europe/Paris" => "Paris",
|
|
188
|
+
"Europe/Amsterdam" => "Amsterdam",
|
|
189
|
+
"Europe/Berlin" => ["Berlin", "Bern"],
|
|
190
|
+
"Europe/Rome" => "Rome",
|
|
191
|
+
"Europe/Stockholm" => "Stockholm",
|
|
192
|
+
"Europe/Vienna" => "Vienna",
|
|
193
|
+
"Africa/Algiers" => "West Central Africa",
|
|
194
|
+
"Europe/Bucharest" => "Bucharest",
|
|
195
|
+
"Africa/Cairo" => "Cairo",
|
|
196
|
+
"Europe/Helsinki" => "Helsinki",
|
|
197
|
+
"Europe/Kiev" => "Kyiv",
|
|
198
|
+
"Europe/Riga" => "Riga",
|
|
199
|
+
"Europe/Sofia" => "Sofia",
|
|
200
|
+
"Europe/Tallinn" => "Tallinn",
|
|
201
|
+
"Europe/Vilnius" => "Vilnius",
|
|
202
|
+
"Europe/Athens" => "Athens",
|
|
203
|
+
"Europe/Istanbul" => "Istanbul",
|
|
204
|
+
"Europe/Minsk" => "Minsk",
|
|
205
|
+
"Asia/Jerusalem" => "Jerusalem",
|
|
206
|
+
"Africa/Harare" => "Harare",
|
|
207
|
+
"Africa/Johannesburg" => "Pretoria",
|
|
208
|
+
"Europe/Moscow" => ["Moscow", "St. Petersburg", "Volgograd"],
|
|
209
|
+
"Asia/Kuwait" => "Kuwait",
|
|
210
|
+
"Asia/Riyadh" => "Riyadh",
|
|
211
|
+
"Africa/Nairobi" => "Nairobi",
|
|
212
|
+
"Asia/Baghdad" => "Baghdad",
|
|
213
|
+
"Asia/Tehran" => "Tehran",
|
|
214
|
+
"Asia/Muscat" => ["Muscat", "Abu Dhabi"],
|
|
215
|
+
"Asia/Baku" => "Baku",
|
|
216
|
+
"Asia/Tbilisi" => "Tbilisi",
|
|
217
|
+
"Asia/Yerevan" => "Yerevan",
|
|
218
|
+
"Asia/Kabul" => "Kabul",
|
|
219
|
+
"Asia/Yekaterinburg" => "Ekaterinburg",
|
|
220
|
+
"Asia/Karachi" => ["Karachi", "Islamabad"],
|
|
221
|
+
"Asia/Tashkent" => "Tashkent",
|
|
222
|
+
"Asia/Kolkata" => ["New Delhi", "Chennai", "Mumbai", "Kolkata"],
|
|
223
|
+
"Asia/Kathmandu" => "Kathmandu",
|
|
224
|
+
"Asia/Dhaka" => ["Dhaka", "Astana"],
|
|
225
|
+
"Asia/Colombo" => "Sri Jayawardenepura",
|
|
226
|
+
"Asia/Almaty" => "Almaty",
|
|
227
|
+
"Asia/Novosibirsk" => "Novosibirsk",
|
|
228
|
+
"Asia/Rangoon" => "Rangoon",
|
|
229
|
+
"Asia/Bangkok" => ["Hanoi", "Bangkok"],
|
|
230
|
+
"Asia/Jakarta" => "Jakarta",
|
|
231
|
+
"Asia/Krasnoyarsk" => "Krasnoyarsk",
|
|
232
|
+
"Asia/Shanghai" => "Beijing",
|
|
233
|
+
"Asia/Chongqing" => "Chongqing",
|
|
234
|
+
"Asia/Hong_Kong" => "Hong Kong",
|
|
235
|
+
"Asia/Urumqi" => "Urumqi",
|
|
236
|
+
"Asia/Kuala_Lumpur" => "Kuala Lumpur",
|
|
237
|
+
"Asia/Singapore" => "Singapore",
|
|
238
|
+
"Asia/Taipei" => "Taipei",
|
|
239
|
+
"Australia/Perth" => "Perth",
|
|
240
|
+
"Asia/Irkutsk" => "Irkutsk",
|
|
241
|
+
"Asia/Ulaanbaatar" => "Ulaan Bataar",
|
|
242
|
+
"Asia/Seoul" => "Seoul",
|
|
243
|
+
"Asia/Tokyo" => ["Tokyo", "Sapporo", "Osaka"],
|
|
244
|
+
"Asia/Yakutsk" => "Yakutsk",
|
|
245
|
+
"Australia/Darwin" => "Darwin",
|
|
246
|
+
"Australia/Adelaide" => "Adelaide",
|
|
247
|
+
"Australia/Melbourne" => ["Melbourne", "Canberra"],
|
|
248
|
+
"Australia/Sydney" => "Sydney",
|
|
249
|
+
"Australia/Brisbane" => "Brisbane",
|
|
250
|
+
"Australia/Hobart" => "Hobart",
|
|
251
|
+
"Asia/Vladivostok" => "Vladivostok",
|
|
252
|
+
"Pacific/Guam" => "Guam",
|
|
253
|
+
"Pacific/Port_Moresby" => "Port Moresby",
|
|
254
|
+
"Asia/Magadan" => ["Solomon Is.", "Magadan"],
|
|
255
|
+
"Pacific/Noumea" => "New Caledonia",
|
|
256
|
+
"Pacific/Fiji" => "Fiji",
|
|
257
|
+
"Asia/Kamchatka" => "Kamchatka",
|
|
258
|
+
"Pacific/Majuro" => "Marshall Is.",
|
|
259
|
+
"Pacific/Auckland" => ["Auckland", "Wellington"],
|
|
260
|
+
"Pacific/Tongatapu" => "Nuku'alofa",
|
|
261
|
+
"Pacific/Fakaofo" => "Tokelau Is.",
|
|
262
|
+
"Pacific/Apia" => "Samoa"
|
|
263
|
+
}.freeze
|
data/ruby-cldr-timezones.gemspec
CHANGED
|
@@ -3,7 +3,8 @@ name = "ruby-cldr-timezones"
|
|
|
3
3
|
require "cldr/timezones/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new name, Cldr::Timezones::VERSION do |s|
|
|
6
|
-
s.summary = "
|
|
6
|
+
s.summary = "Translated timezones according to CLDR"
|
|
7
|
+
s.description = "Get the translated timezones according to CLDR. Support for 573 languages."
|
|
7
8
|
s.authors = ["Ana Martinez"]
|
|
8
9
|
s.email = "acemacu@gmail.com"
|
|
9
10
|
s.homepage = "https://github.com/anamartinez/#{name}"
|
data/spec/cldr_timezones_spec.rb
CHANGED
|
@@ -13,27 +13,27 @@ describe Cldr::Timezones do
|
|
|
13
13
|
|
|
14
14
|
it "builds a list with translations" do
|
|
15
15
|
timezones = Cldr::Timezones.list(:es)
|
|
16
|
-
timezones["Europe/Moscow"].should
|
|
17
|
-
timezones["America/Sao_Paulo"].should
|
|
16
|
+
timezones["Europe/Moscow"].should match(/\(GMT\+0\d:00\) Moscú/)
|
|
17
|
+
timezones["America/Sao_Paulo"].should match(/\(GMT-0\d:00\) São Paulo/)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "builds a list with translations" do
|
|
21
|
-
timezones = Cldr::Timezones.list(:"es-MX",
|
|
22
|
-
timezones["America/Indiana/Knox"].should
|
|
23
|
-
timezones["Asia/Saigon"].should
|
|
21
|
+
timezones = Cldr::Timezones.list(:"es-MX", :full)
|
|
22
|
+
timezones["America/Indiana/Knox"].should match(/\(GMT-0\d:00\) Knox, Indiana/)
|
|
23
|
+
timezones["Asia/Saigon"].should match(/\(GMT\+0\d:00\) Ho Chi Minh/)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Checks that fallback is working since Moscú is only in "es"
|
|
27
27
|
it "builds a list with translations using fallback" do
|
|
28
28
|
timezones = Cldr::Timezones.list(:"es-MX")
|
|
29
|
-
timezones["Europe/Moscow"].should
|
|
30
|
-
timezones["America/Sao_Paulo"].should
|
|
29
|
+
timezones["Europe/Moscow"].should match(/\(GMT\+0\d:00\) Moscú/)
|
|
30
|
+
timezones["America/Sao_Paulo"].should match(/\(GMT-0\d:00\) São Paulo/)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "builds a list with translations using fallback en-US" do
|
|
34
34
|
timezones = Cldr::Timezones.list(:"en-US")
|
|
35
|
-
timezones["Europe/Moscow"].should
|
|
36
|
-
timezones["America/Sao_Paulo"].should
|
|
35
|
+
timezones["Europe/Moscow"].should match(/\(GMT\+0\d:00\) Moscow/)
|
|
36
|
+
timezones["America/Sao_Paulo"].should match(/\(GMT-0\d:00\) Sao Paulo/)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "builds a list with meaningful subset" do
|
|
@@ -42,8 +42,49 @@ describe Cldr::Timezones do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "builds the complete set if true is passed" do
|
|
45
|
-
timezones = Cldr::Timezones.list(:ja,
|
|
46
|
-
timezones.size.should equal(
|
|
45
|
+
timezones = Cldr::Timezones.list(:ja, :full)
|
|
46
|
+
timezones.size.should equal(584)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "builds the timezone with the ActiveSupport identifier with a partial list" do
|
|
50
|
+
timezones = Cldr::Timezones.list(:es, :rails_identifiers)
|
|
51
|
+
timezones["St. Petersburg"].should match(/\(GMT\+0\d:00\) Moscú/)
|
|
52
|
+
timezones["Moscow"].should match(/\(GMT\+0\d:00\) Moscú/)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "builds the timezone with the ActiveSupport identifier with a full list" do
|
|
56
|
+
timezones = Cldr::Timezones.list(:es, {:full => true, :rails_identifiers => true})
|
|
57
|
+
timezones["St. Petersburg"].should match(/\(GMT\+0\d:00\) Moscú/)
|
|
58
|
+
timezones["Zulu"].should match(/\(GMT\+0\d:00\) Zulu/)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe ".raw" do
|
|
63
|
+
it "builds a list with translations" do
|
|
64
|
+
timezones = Cldr::Timezones.raw(:pt)
|
|
65
|
+
timezones["Europe/Moscow"][0].should eq("Moscou")
|
|
66
|
+
timezones["Europe/Moscow"][1].should match(/\+0\d:00/)
|
|
67
|
+
timezones["Europe/Moscow"][2].should eq("GMT")
|
|
68
|
+
timezones["America/Sao_Paulo"][0].should eq("São Paulo")
|
|
69
|
+
timezones["America/Sao_Paulo"][1].should match(/\-0\d:00/)
|
|
70
|
+
timezones["America/Sao_Paulo"][2].should eq("GMT")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "builds a list with the ActiveSupport identifier" do
|
|
74
|
+
timezones = Cldr::Timezones.raw(:pt, :rails_identifiers)
|
|
75
|
+
timezones["St. Petersburg"][0].should eq("Moscou")
|
|
76
|
+
timezones["St. Petersburg"][1].should match(/\+0\d:00/)
|
|
77
|
+
timezones["St. Petersburg"][2].should eq("GMT")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "builds a list with translations using fallback" do
|
|
81
|
+
timezones = Cldr::Timezones.raw(:"es-MX")
|
|
82
|
+
timezones["Europe/Moscow"][0].should eq("Moscú")
|
|
83
|
+
timezones["Europe/Moscow"][1].should match(/\+0\d:00/)
|
|
84
|
+
timezones["Europe/Moscow"][2].should eq("GMT")
|
|
85
|
+
timezones["America/Sao_Paulo"][0].should eq("São Paulo")
|
|
86
|
+
timezones["America/Sao_Paulo"][1].should match(/\-0\d:00/)
|
|
87
|
+
timezones["America/Sao_Paulo"][2].should eq("GMT")
|
|
47
88
|
end
|
|
48
89
|
end
|
|
49
90
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-cldr-timezones
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: tzinfo
|
|
@@ -27,7 +27,7 @@ dependencies:
|
|
|
27
27
|
- - ! '>='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0'
|
|
30
|
-
description:
|
|
30
|
+
description: Get the translated timezones according to CLDR. Support for 573 languages.
|
|
31
31
|
email: acemacu@gmail.com
|
|
32
32
|
executables: []
|
|
33
33
|
extensions: []
|
|
@@ -1850,5 +1850,5 @@ rubyforge_project:
|
|
|
1850
1850
|
rubygems_version: 1.8.25
|
|
1851
1851
|
signing_key:
|
|
1852
1852
|
specification_version: 3
|
|
1853
|
-
summary:
|
|
1853
|
+
summary: Translated timezones according to CLDR
|
|
1854
1854
|
test_files: []
|