iso 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/iso.gemspec CHANGED
@@ -5,56 +5,77 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{iso}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Christopher Dell}]
12
- s.date = %q{2012-09-02}
13
- s.description = %q{A ruby implementation of ISO languages and regions and they're translation data (such as language direction, pluralization rules).}
12
+ s.date = %q{2012-09-03}
13
+ s.description = %q{A subset of the ISO spec implemented in ruby}
14
14
  s.email = %q{chris@tigrish.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
+ "Guardfile",
24
25
  "LICENSE.txt",
25
- "README.rdoc",
26
+ "README.md",
26
27
  "Rakefile",
27
28
  "VERSION",
29
+ "data/iso-3166-1.yml",
30
+ "data/iso-639-1.yml",
28
31
  "iso.gemspec",
29
32
  "lib/iso.rb",
30
- "spec/iso_spec.rb",
33
+ "lib/iso/language.rb",
34
+ "lib/iso/region.rb",
35
+ "lib/iso/subtag.rb",
36
+ "lib/iso/tag.rb",
37
+ "locales/en.yml",
38
+ "spec/fixtures/base.yml",
39
+ "spec/lib/iso/language_spec.rb",
40
+ "spec/lib/iso/region_spec.rb",
41
+ "spec/lib/iso/subtag_spec.rb",
42
+ "spec/lib/iso/tag_spec.rb",
31
43
  "spec/spec_helper.rb"
32
44
  ]
33
45
  s.homepage = %q{http://github.com/tigrish/iso}
34
46
  s.licenses = [%q{MIT}]
35
47
  s.require_paths = [%q{lib}]
36
48
  s.rubygems_version = %q{1.8.6}
37
- s.summary = %q{A ruby implementation of ISO languages and regions and they're translation data.}
49
+ s.summary = %q{A ruby implementation of ISO}
38
50
 
39
51
  if s.respond_to? :specification_version then
40
52
  s.specification_version = 3
41
53
 
42
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
43
56
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
44
57
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
45
58
  s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
46
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
60
+ s.add_development_dependency(%q<guard-rspec>, [">= 0"])
61
+ s.add_development_dependency(%q<localeapp>, [">= 0"])
47
62
  else
63
+ s.add_dependency(%q<i18n>, [">= 0"])
48
64
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
49
65
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
50
66
  s.add_dependency(%q<bundler>, ["~> 1.2.0"])
51
67
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
68
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
69
+ s.add_dependency(%q<localeapp>, [">= 0"])
52
70
  end
53
71
  else
72
+ s.add_dependency(%q<i18n>, [">= 0"])
54
73
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55
74
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
75
  s.add_dependency(%q<bundler>, ["~> 1.2.0"])
57
76
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
77
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
78
+ s.add_dependency(%q<localeapp>, [">= 0"])
58
79
  end
59
80
  end
60
81
 
data/lib/iso.rb CHANGED
@@ -0,0 +1,8 @@
1
+ require 'i18n'
2
+ I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../locales'), '*.yml')]
3
+ I18n.load_path.flatten!
4
+
5
+ require 'iso/tag'
6
+ require 'iso/subtag'
7
+ require 'iso/language'
8
+ require 'iso/region'
@@ -0,0 +1,25 @@
1
+ class ISO::Language < ISO::Subtag
2
+ DEFINITIONS_FILE = "#{File.dirname(__FILE__)}/../../data/iso-639-1.yml"
3
+ DEFAULT_PLURAL_RULE_NAMES = %w(one other)
4
+ DEFAULT_DIRECTION = 'ltr'
5
+ DEFAULT_CODE = 'en'
6
+ PLURAL_RULE_NAMES = %w(zero one two few many other)
7
+
8
+ attr_reader :plural_rule_names, :direction
9
+
10
+ def initialize(code, options={})
11
+ @plural_rule_names = options[:plural_rule_names] || DEFAULT_PLURAL_RULE_NAMES
12
+ @direction = options[:direction] || DEFAULT_DIRECTION
13
+ super(code, options)
14
+ end
15
+
16
+ def self.identify(full_code)
17
+ segments = full_code.split('-')
18
+ segments.first =~ /^([a-z]{2})$/ ? find($1) : nil
19
+ end
20
+
21
+ private
22
+ def i18n_scope
23
+ super << ".languages"
24
+ end
25
+ end
data/lib/iso/region.rb ADDED
@@ -0,0 +1,12 @@
1
+ class ISO::Region < ISO::Subtag
2
+ DEFINITIONS_FILE = "#{File.dirname(__FILE__)}/../../data/iso-3166-1.yml"
3
+
4
+ def self.identify(full_code)
5
+ full_code =~ /[-_]([A-Z]{2})$/ ? find($1) : nil
6
+ end
7
+
8
+ private
9
+ def i18n_scope
10
+ super << ".regions"
11
+ end
12
+ end
data/lib/iso/subtag.rb ADDED
@@ -0,0 +1,46 @@
1
+ module ISO
2
+ class Subtag
3
+ attr_reader :code
4
+
5
+ def initialize(code, options={})
6
+ @code = code
7
+ end
8
+
9
+ def ==(object)
10
+ code == object.code
11
+ end
12
+
13
+ def name
14
+ I18n.t(code, scope: i18n_scope)
15
+ end
16
+
17
+ def full_name
18
+ "#{code} - #{name}"
19
+ end
20
+
21
+ def self.all
22
+ YAML.load_file(self::DEFINITIONS_FILE).map do |code, options|
23
+ symbolized_options = {}
24
+ options.keys.each { |key| symbolized_options[key.to_sym] = options[key] } if options
25
+ new(code, symbolized_options)
26
+ end
27
+ end
28
+
29
+ def self.find(code)
30
+ all.find {|subtag| subtag.code == code }
31
+ end
32
+
33
+ def self.default
34
+ find(self::DEFAULT_CODE)
35
+ end
36
+
37
+ def self.codes
38
+ all.map(&:code)
39
+ end
40
+
41
+ private
42
+ def i18n_scope
43
+ %w(vendor iso).join('.')
44
+ end
45
+ end
46
+ end
data/lib/iso/tag.rb ADDED
@@ -0,0 +1,19 @@
1
+ module ISO
2
+ class Tag
3
+ attr_accessor :language, :region
4
+
5
+ def initialize(code)
6
+ @code = code
7
+ @language = Language.identify(code)
8
+ @region = Region.identify(code)
9
+ end
10
+
11
+ def codes
12
+ subtags.map(&:code)
13
+ end
14
+
15
+ def subtags
16
+ [language, region].compact
17
+ end
18
+ end
19
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,435 @@
1
+ en:
2
+ vendor:
3
+ iso:
4
+ languages:
5
+ aa: Afar
6
+ ab: Abkhazian
7
+ ae: Avestan
8
+ af: Afrikaans
9
+ ak: Akan
10
+ am: Amharic
11
+ an: Aragonese
12
+ ar: Arabic
13
+ as: Assamese
14
+ av: Avaric
15
+ ay: Aymara
16
+ az: Azerbaijani
17
+ ba: Bashkir
18
+ be: Belarusian
19
+ bg: Bulgarian
20
+ bh: Bihari
21
+ bi: Bislama
22
+ bm: Bambara
23
+ bn: Bengali
24
+ bo: Tibetan
25
+ br: Breton
26
+ bs: Bosnian
27
+ ca: Catalan
28
+ ce: Chechen
29
+ ch: Chamorro
30
+ co: Corsican
31
+ cr: Cree
32
+ cs: Czech
33
+ cu: Church Slavic
34
+ cv: Chuvash
35
+ cy: Welsh
36
+ da: Danish
37
+ de: German
38
+ dv: Divehi
39
+ dz: Dzongkha
40
+ ee: Ewe
41
+ el: Greek
42
+ en: English
43
+ eo: Esperanto
44
+ es: Spanish
45
+ et: Estonian
46
+ eu: Basque
47
+ fa: Persian
48
+ ff: Fulah
49
+ fi: Finnish
50
+ fj: Fijian
51
+ fo: Faroese
52
+ fr: French
53
+ fy: Western Frisian
54
+ ga: Irish
55
+ gd: Gaelic
56
+ gl: Galician
57
+ gn: Guarani
58
+ gu: Gujarati
59
+ gv: Manx
60
+ ha: Hausa
61
+ he: Hebrew
62
+ hi: Hindi
63
+ ho: Hiri Motu
64
+ hr: Croatian
65
+ ht: Haitian
66
+ hu: Hungarian
67
+ hy: Armenian
68
+ hz: Herero
69
+ ia: Interlingua
70
+ id: Indonesian
71
+ ie: Interlingue
72
+ ig: Igbo
73
+ ii: Sichuan Yi
74
+ ik: Inupiaq
75
+ io: Ido
76
+ is: Icelandic
77
+ it: Italian
78
+ iu: Inuktitut
79
+ ja: Japanese
80
+ jv: Javanese
81
+ ka: Georgian
82
+ kg: Kongo
83
+ ki: Kikuyu
84
+ kj: Kuanyama
85
+ kk: Kazakh
86
+ kl: Kalaallisut
87
+ km: Central Khmer
88
+ kn: Kannada
89
+ ko: Korean
90
+ kr: Kanuri
91
+ ks: Kashmiri
92
+ ku: Kurdish
93
+ kv: Komi
94
+ kw: Cornish
95
+ ky: Kirghiz
96
+ la: Latin
97
+ lb: Luxembourgish
98
+ lg: Ganda
99
+ li: Limburgan
100
+ ln: Lingala
101
+ lo: Lao
102
+ lt: Lithuanian
103
+ lu: Luba-Katanga
104
+ lv: Latvian
105
+ mg: Malagasy
106
+ mh: Marshallese
107
+ mi: Maori
108
+ mk: Macedonian
109
+ ml: Malayalam
110
+ mn: Mongolian
111
+ mr: Marathi
112
+ ms: Malay
113
+ mt: Maltese
114
+ my: Burmese
115
+ na: Nauru
116
+ nb: Norwegian Bokmål
117
+ nd: North Ndebele
118
+ ne: Nepali
119
+ ng: Ndonga
120
+ nl: Dutch
121
+ nn: Norwegian Nynorsk
122
+ false: Norwegian
123
+ nr: South Ndebele
124
+ nv: Navajo
125
+ ny: Chichewa
126
+ oc: Occitan
127
+ oj: Ojibwa
128
+ om: Oromo
129
+ or: Oriya
130
+ os: Ossetian
131
+ pa: Panjabi
132
+ pi: Pali
133
+ pl: Polish
134
+ ps: Pushto
135
+ pt: Portuguese
136
+ qu: Quechua
137
+ rm: Romansh
138
+ rn: Rundi
139
+ ro: Romanian
140
+ ru: Russian
141
+ rw: Kinyarwanda
142
+ sa: Sanskrit
143
+ sc: Sardinian
144
+ sd: Sindhi
145
+ se: Northern Sami
146
+ sg: Sango
147
+ si: Sinhala
148
+ sk: Slovak
149
+ sl: Slovenian
150
+ sm: Samoan
151
+ sn: Shona
152
+ so: Somali
153
+ sq: Albanian
154
+ sr: Serbian
155
+ ss: Swati
156
+ st: Sotho, Southern
157
+ su: Sundanese
158
+ sv: Swedish
159
+ sw: Swahili
160
+ ta: Tamil
161
+ te: Telugu
162
+ tg: Tajik
163
+ th: Thai
164
+ ti: Tigrinya
165
+ tk: Turkmen
166
+ tl: Tagalog
167
+ tn: Tswana
168
+ to: Tonga
169
+ tr: Turkish
170
+ ts: Tsonga
171
+ tt: Tatar
172
+ tw: Twi
173
+ ty: Tahitian
174
+ ug: Uighur
175
+ uk: Ukrainian
176
+ ur: Urdu
177
+ uz: Uzbek
178
+ ve: Venda
179
+ vo: Volapuk
180
+ vi: Vietnamese
181
+ wa: Walloon
182
+ wo: Wolof
183
+ xh: Xhosa
184
+ yi: Yiddish
185
+ yo: Yoruba
186
+ za: Zhuang
187
+ zh: Chinese
188
+ zu: Zulu
189
+ regions:
190
+ AF: Afghanistan
191
+ AX: Aland Islands
192
+ AL: Albania
193
+ DZ: Algeria
194
+ AS: American Samoa
195
+ AD: Andorra
196
+ AO: Angola
197
+ AI: Anguilla
198
+ AQ: Antarctica
199
+ AG: Antigua and Barbuda
200
+ AR: Argentina
201
+ AM: Armenia
202
+ AW: Aruba
203
+ AU: Australia
204
+ AT: Austria
205
+ AZ: Azerbaijan
206
+ BS: Bahamas
207
+ BH: Bahrain
208
+ BD: Bangladesh
209
+ BB: Barbados
210
+ BY: Belarus
211
+ BE: Belgium
212
+ BZ: Belize
213
+ BJ: Benin
214
+ BM: Bermuda
215
+ BT: Bhutan
216
+ BO: Bolivia
217
+ BA: Bosnia and Herzegovina
218
+ BW: Botswana
219
+ BV: Bouvet Island
220
+ BR: Brazil
221
+ IO: British Indian Ocean Territory
222
+ BN: Brunei Darussalam
223
+ BG: Bulgaria
224
+ BF: Burkina Faso
225
+ BI: Burundi
226
+ KH: Cambodia
227
+ CM: Cameroon
228
+ CA: Canada
229
+ CV: Cape Verde
230
+ KY: Cayman Islands
231
+ CF: Central African Republic
232
+ TD: Chad
233
+ CL: Chile
234
+ CN: China
235
+ CX: Christmas Island
236
+ CC: Cocos (Keeling) Islands
237
+ CO: Colombia
238
+ KM: Comoros
239
+ CD: Congo, the Democratic Republic of the
240
+ CG: Congo
241
+ CK: Cook Islands
242
+ CR: Costa Rica
243
+ CI: Cote D'Ivoire
244
+ HR: Croatia
245
+ CU: Cuba
246
+ CY: Cyprus
247
+ CZ: Czech Republic
248
+ DK: Denmark
249
+ DJ: Djibouti
250
+ DM: Dominica
251
+ DO: Dominican Republic
252
+ EC: Ecuador
253
+ EG: Egypt
254
+ SV: El Salvador
255
+ GQ: Equatorial Guinea
256
+ ER: Eritrea
257
+ EE: Estonia
258
+ ET: Ethiopia
259
+ FK: Falkland Islands (Malvinas)
260
+ FO: Faroe Islands
261
+ FJ: Fiji
262
+ FI: Finland
263
+ FR: France
264
+ GF: French Guiana
265
+ PF: French Polynesia
266
+ TF: French Southern Territories
267
+ GA: Gabon
268
+ GM: Gambia
269
+ GE: Georgia
270
+ DE: Germany
271
+ GH: Ghana
272
+ GI: Gibraltar
273
+ GR: Greece
274
+ GL: Greenland
275
+ GD: Grenada
276
+ GP: Guadeloupe
277
+ GU: Guam
278
+ GT: Guatemala
279
+ GG: Guernsey
280
+ GN: Guinea
281
+ GW: Guinea-Bissau
282
+ GY: Guyana
283
+ HT: Haiti
284
+ HM: Heard Island and Mcdonald Islands
285
+ HN: Honduras
286
+ HK: Hong Kong
287
+ HU: Hungary
288
+ IS: Iceland
289
+ IN: India
290
+ ID: Indonesia
291
+ IR: Iran (Islamic Republic of)
292
+ IQ: Iraq
293
+ IE: Ireland
294
+ IM: Isle of Man
295
+ IL: Israel
296
+ IT: Italy
297
+ JM: Jamaica
298
+ JP: Japan
299
+ JE: Jersey
300
+ JO: Jordan
301
+ KZ: Kazakhstan
302
+ KE: Kenya
303
+ KI: Kiribati
304
+ KP: Korea, Democratic People'S Republic of
305
+ KR: Korea, Republic of
306
+ KW: Kuwait
307
+ KG: Kyrgyzstan
308
+ LA: Lao People'S Democratic Republic
309
+ LV: Latvia
310
+ LB: Lebanon
311
+ LS: Lesotho
312
+ LR: Liberia
313
+ LY: Libyan Arab Jamahiriya
314
+ LI: Liechtenstein
315
+ LT: Lithuania
316
+ LU: Luxembourg
317
+ MO: Macao
318
+ MK: Macedonia, the Former Yugoslav Republic of
319
+ MG: Madagascar
320
+ MW: Malawi
321
+ MY: Malaysia
322
+ MV: Maldives
323
+ ML: Mali
324
+ MT: Malta
325
+ MH: Marshall Islands
326
+ MQ: Martinique
327
+ MR: Mauritania
328
+ MU: Mauritius
329
+ YT: Mayotte
330
+ MX: Mexico
331
+ FM: Micronesia, Federated States of
332
+ MD: Moldova, Republic of
333
+ MC: Monaco
334
+ MN: Mongolia
335
+ ME: Montenegro
336
+ MS: Montserrat
337
+ MA: Morocco
338
+ MZ: Mozambique
339
+ MM: Myanmar
340
+ NA: Namibia
341
+ NR: Nauru
342
+ NP: Nepal
343
+ NL: Netherlands
344
+ AN: Netherlands Antilles
345
+ NC: New Caledonia
346
+ NZ: New Zealand
347
+ NI: Nicaragua
348
+ NE: Niger
349
+ NG: Nigeria
350
+ NU: Niue
351
+ NF: Norfolk Island
352
+ MP: Northern Mariana Islands
353
+ 'NO': Norway
354
+ OM: Oman
355
+ PK: Pakistan
356
+ PW: Palau
357
+ PS: Palestinian Territory, Occupied
358
+ PA: Panama
359
+ PG: Papua New Guinea
360
+ PY: Paraguay
361
+ PE: Peru
362
+ PH: Philippines
363
+ PN: Pitcairn
364
+ PL: Poland
365
+ PT: Portugal
366
+ PR: Puerto Rico
367
+ QA: Qatar
368
+ RE: Reunion
369
+ RO: Romania
370
+ RU: Russian Federation
371
+ RW: Rwanda
372
+ BL: Saint Barthelemy
373
+ SH: Saint Helena
374
+ KN: Saint Kitts and Nevis
375
+ LC: Saint Lucia
376
+ MF: Saint Martin (French Part)
377
+ PM: Saint Pierre and Miquelon
378
+ VC: Saint Vincent and the Grenadines
379
+ WS: Samoa
380
+ SM: San Marino
381
+ ST: Sao Tome and Principe
382
+ SA: Saudi Arabia
383
+ SN: Senegal
384
+ RS: Serbia
385
+ SC: Seychelles
386
+ SL: Sierra Leone
387
+ SG: Singapore
388
+ SK: Slovakia
389
+ SI: Slovenia
390
+ SB: Solomon Islands
391
+ SO: Somalia
392
+ ZA: South Africa
393
+ GS: South Georgia and the South Sandwich Islands
394
+ ES: Spain
395
+ LK: Sri Lanka
396
+ SD: Sudan
397
+ SR: Suriname
398
+ SJ: Svalbard and Jan Mayen
399
+ SZ: Swaziland
400
+ SE: Sweden
401
+ CH: Switzerland
402
+ SY: Syrian Arab Republic
403
+ TW: Taiwan
404
+ TJ: Tajikistan
405
+ TZ: Tanzania, United Republic of
406
+ TH: Thailand
407
+ TL: Timor-Leste
408
+ TG: Togo
409
+ TK: Tokelau
410
+ TO: Tonga
411
+ TT: Trinidad and Tobago
412
+ TN: Tunisia
413
+ TR: Turkey
414
+ TM: Turkmenistan
415
+ TC: Turks and Caicos Islands
416
+ TV: Tuvalu
417
+ UG: Uganda
418
+ UA: Ukraine
419
+ AE: United Arab Emirates
420
+ GB: United Kingdom
421
+ US: United States
422
+ UM: United States Minor Outlying Islands
423
+ UY: Uruguay
424
+ UZ: Uzbekistan
425
+ VU: Vanuatu
426
+ VA: Vatican City State (Holy See)
427
+ VE: Venezuela
428
+ VN: Vietnam
429
+ VG: Virgin Islands (British)
430
+ VI: Virgin Islands (U.S.)
431
+ WF: Wallis and Futuna
432
+ EH: Western Sahara
433
+ YE: Yemen
434
+ ZM: Zambia
435
+ ZW: Zimbabwe