i18n_countries 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d22fbe50a4d8f88a9bc3c87df8d0b98c1a44b1af98003d0ef29be6486d4a54f
4
- data.tar.gz: 4c3800758eed7535fc858c7347aa0d60d1a442336de84d6881d6cf44e54900bd
3
+ metadata.gz: 33287df6b658b287adf9029ebbed3cb70677d47698ce8e7b03efb5daf2818901
4
+ data.tar.gz: 67e0d8c07f89034899256ec22cf79f4e907815f929132fa93d07b2ef9f6531fd
5
5
  SHA512:
6
- metadata.gz: 592dd9b11416c5bf07c9d22cabd8e554cf9734671122d464e999d98adffcbf5811d1c7948d1eabf6a9dcd2be0d35ea8a26f8af54f03e1178eff394eeaff30380
7
- data.tar.gz: c3ec716d925fc4688718588ab224714771fdeda3c175074e8d71caabad1ec8a12e81df46f81cf855cd5584299def971b31bf34c50ca47d8c305f5fb2ae183f9b
6
+ metadata.gz: 20addd4ed222c3459d0c8043e3c6afba0ca8a5af36df983ac00f1a1a8780178468bbea94ce0dda75e5f893ec0bda39c07f4c7cdc0741d8f23bd8ac3c031b19be
7
+ data.tar.gz: 26f4f13d3758d4732318726c89a6082e41d385280c370fea08c2ed444be62c2edb67eefb487ffa4b4dd5dff4af17c57c2736b67c4f3269d5f1e19db3b29f3851
data/.byebug_history CHANGED
@@ -1,4 +1,92 @@
1
1
  c
2
+ e
3
+ n
4
+ name
5
+ s
6
+ exit
7
+ l
8
+ i18n_countries.codes.length
9
+ i18n_countries.instance_variables_get(:@codes)
10
+ i18n_countries.instance_variables
11
+ i18n_countries.codes
12
+ i18n_countries.method(:codes)
13
+ i18n_countries.methods
14
+ i18n_countries.methods(:codes)
15
+ i18n_countries.methods[:codes]
16
+ i18n_countries.codes
17
+ c
18
+ @codes['US']['a3']
19
+ @codes['US']['numeric']
20
+ @codes['AF']['numeric']
21
+ @codes['AF']['a3']
22
+ @codes.count
23
+ @codes['AF']
24
+ @codes
25
+ exit
26
+ @codes
27
+ c
28
+ exit
29
+ @codes
30
+ c
31
+ n
32
+ exit
33
+ @codes['AF']
34
+ c
35
+ exit
36
+ @codes.keys.first.strip.length
37
+ @codes.keys.first.length
38
+ @codes.keys.first
39
+ @codes['AF']
40
+ @codes
41
+ c
42
+ exit
43
+ row[0][0].ord
44
+ row[0][0]
45
+ row[0].length
46
+ row[0]
47
+ c
48
+ exit
49
+ @codes['AF']
50
+ @codes
51
+ c
52
+ exit
53
+ c
54
+ @codes.keys.first.length
55
+ @codes.keys.first.len
56
+ @codes.keys.first[2]
57
+ @codes.keys.first[1]
58
+ @codes.keys.first[0]
59
+ @codes[@codes.keys.first]
60
+ @codes['AF']
61
+ @codes['AL']
62
+ @codes
63
+ c
64
+ @codes["AF"]
65
+ @codes.keys
66
+ @codes['AF']
67
+ @codes
68
+ c
69
+ @codes
70
+ c
71
+ @codes
72
+ row
73
+ c
74
+ i18n_countries.codes.first.key
75
+ i18n_countries.codes.first
76
+ i18n_countries.codes
77
+ c
78
+ my_dir
79
+ File.directory?(dirs.first)
80
+ dirs.first
81
+ dirs
82
+ c
83
+ localized_country_files
84
+ c
85
+ i18n_countries.countries
86
+ i18n_countries
87
+ i18n.countries
88
+ locales
89
+ c
2
90
  i18n_countries.countries['en_US']['JP']
3
91
  i18n_countries.countries['en_US']['JA']
4
92
  i18n_countries.countries['en_US']
data/Gemfile CHANGED
@@ -6,5 +6,4 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
9
  gem "rspec", "~> 3.0"
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n_countries (0.1.0.pre)
4
+ i18n_countries (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- byebug (11.1.3)
10
9
  diff-lcs (1.5.0)
11
10
  rake (13.0.6)
12
11
  rspec (3.11.0)
@@ -27,7 +26,6 @@ PLATFORMS
27
26
  x86_64-darwin-21
28
27
 
29
28
  DEPENDENCIES
30
- byebug
31
29
  i18n_countries!
32
30
  rake (~> 13.0)
33
31
  rspec (~> 3.0)
data/README.md CHANGED
@@ -13,14 +13,19 @@ If bundler is not being used to manage dependencies, install the gem by executin
13
13
  $ gem install i18n_countries
14
14
 
15
15
  ## Usage
16
-
16
+ Country lookup is done with ISO Alpha-2 code:
17
17
  $ require 'i18n_countries'
18
- $ countries = I18nCountries.new
19
- $ countries['en_US']['JP']) # -> 'Japan'
18
+ $ i18nc = I18nCountries.new
20
19
 
21
- ## Development
20
+ The returned object has two hashes. 'countries' contains a hash of hashes keyed
21
+ on locale and Alpha-2 code:
22
+ $ i18nc.countries['en_US']['JP']) # -> 'Japan'
22
23
 
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+ Alpha 3 and numeric codes are available in the 'codes' hash:
25
+ $ i18nc.codes['JP']['a3'] # -> 'JPN'
26
+ $ i18nc.codes['JP']['numeric'] # -> 392
27
+
28
+ ## Development
24
29
 
25
30
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
31
 
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/i18n_countries"
4
+ require_relative "lib/i18n_countries/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "i18n_countries"
8
+ spec.version = I18nCountries::VERSION
9
+ spec.authors = ["Steve Brown"]
10
+ spec.email = ["steve@zergsoft.com"]
11
+
12
+ spec.summary = "Generate a hash of multilingual country names."
13
+ spec.description = "Generates a hash of mulitilingual country names for 628 locales."
14
+ spec.homepage = "https://github.com/jpgeek/i18n_countries"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.6.0"
17
+
18
+ #spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ spec.metadata["changelog_uri"] = spec.homepage + '/CHANGES'
23
+
24
+ # Specify which files should be added to the gem when it is released. The
25
+ # `git ls-files -z` loads the files in the RubyGem that have been added into
26
+ # git.
27
+ spec.files = Dir.chdir(__dir__) do
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
30
+ end
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ # Uncomment to register a new dependency of your gem
37
+ # spec.add_dependency "example-gem", "~> 1.0"
38
+
39
+ # For more information and examples about making a new gem, check out our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
@@ -0,0 +1,249 @@
1
+ AF,AFG,4
2
+ AL,ALB,8
3
+ DZ,DZA,12
4
+ AS,ASM,16
5
+ AD,AND,20
6
+ AO,AGO,24
7
+ AI,AIA,660
8
+ AQ,ATA,10
9
+ AG,ATG,28
10
+ AR,ARG,32
11
+ AM,ARM,51
12
+ AW,ABW,533
13
+ AU,AUS,36
14
+ AT,AUT,40
15
+ AZ,AZE,31
16
+ BS,BHS,44
17
+ BH,BHR,48
18
+ BD,BGD,50
19
+ BB,BRB,52
20
+ BY,BLR,112
21
+ BE,BEL,56
22
+ BZ,BLZ,84
23
+ BJ,BEN,204
24
+ BM,BMU,60
25
+ BT,BTN,64
26
+ BO,BOL,68
27
+ BQ,BES,535
28
+ BA,BIH,70
29
+ BW,BWA,72
30
+ BV,BVT,74
31
+ BR,BRA,76
32
+ IO,IOT,86
33
+ BN,BRN,96
34
+ BG,BGR,100
35
+ BF,BFA,854
36
+ BI,BDI,108
37
+ CV,CPV,132
38
+ KH,KHM,116
39
+ CM,CMR,120
40
+ CA,CAN,124
41
+ KY,CYM,136
42
+ CF,CAF,140
43
+ TD,TCD,148
44
+ CL,CHL,152
45
+ CN,CHN,156
46
+ CX,CXR,162
47
+ CC,CCK,166
48
+ CO,COL,170
49
+ KM,COM,174
50
+ CD,COD,180
51
+ CG,COG,178
52
+ CK,COK,184
53
+ CR,CRI,188
54
+ HR,HRV,191
55
+ CU,CUB,192
56
+ CW,CUW,531
57
+ CY,CYP,196
58
+ CZ,CZE,203
59
+ CI,CIV,384
60
+ DK,DNK,208
61
+ DJ,DJI,262
62
+ DM,DMA,212
63
+ DO,DOM,214
64
+ EC,ECU,218
65
+ EG,EGY,818
66
+ SV,SLV,222
67
+ GQ,GNQ,226
68
+ ER,ERI,232
69
+ EE,EST,233
70
+ SZ,SWZ,748
71
+ ET,ETH,231
72
+ FK,FLK,238
73
+ FO,FRO,234
74
+ FJ,FJI,242
75
+ FI,FIN,246
76
+ FR,FRA,250
77
+ GF,GUF,254
78
+ PF,PYF,258
79
+ TF,ATF,260
80
+ GA,GAB,266
81
+ GM,GMB,270
82
+ GE,GEO,268
83
+ DE,DEU,276
84
+ GH,GHA,288
85
+ GI,GIB,292
86
+ GR,GRC,300
87
+ GL,GRL,304
88
+ GD,GRD,308
89
+ GP,GLP,312
90
+ GU,GUM,316
91
+ GT,GTM,320
92
+ GG,GGY,831
93
+ GN,GIN,324
94
+ GW,GNB,624
95
+ GY,GUY,328
96
+ HT,HTI,332
97
+ HM,HMD,334
98
+ VA,VAT,336
99
+ HN,HND,340
100
+ HK,HKG,344
101
+ HU,HUN,348
102
+ IS,ISL,352
103
+ IN,IND,356
104
+ ID,IDN,360
105
+ IR,IRN,364
106
+ IQ,IRQ,368
107
+ IE,IRL,372
108
+ IM,IMN,833
109
+ IL,ISR,376
110
+ IT,ITA,380
111
+ JM,JAM,388
112
+ JP,JPN,392
113
+ JE,JEY,832
114
+ JO,JOR,400
115
+ KZ,KAZ,398
116
+ KE,KEN,404
117
+ KI,KIR,296
118
+ KP,PRK,408
119
+ KR,KOR,410
120
+ KW,KWT,414
121
+ KG,KGZ,417
122
+ LA,LAO,418
123
+ LV,LVA,428
124
+ LB,LBN,422
125
+ LS,LSO,426
126
+ LR,LBR,430
127
+ LY,LBY,434
128
+ LI,LIE,438
129
+ LT,LTU,440
130
+ LU,LUX,442
131
+ MO,MAC,446
132
+ MG,MDG,450
133
+ MW,MWI,454
134
+ MY,MYS,458
135
+ MV,MDV,462
136
+ ML,MLI,466
137
+ MT,MLT,470
138
+ MH,MHL,584
139
+ MQ,MTQ,474
140
+ MR,MRT,478
141
+ MU,MUS,480
142
+ YT,MYT,175
143
+ MX,MEX,484
144
+ FM,FSM,583
145
+ MD,MDA,498
146
+ MC,MCO,492
147
+ MN,MNG,496
148
+ ME,MNE,499
149
+ MS,MSR,500
150
+ MA,MAR,504
151
+ MZ,MOZ,508
152
+ MM,MMR,104
153
+ NA,NAM,516
154
+ NR,NRU,520
155
+ NP,NPL,524
156
+ NL,NLD,528
157
+ NC,NCL,540
158
+ NZ,NZL,554
159
+ NI,NIC,558
160
+ NE,NER,562
161
+ NG,NGA,566
162
+ NU,NIU,570
163
+ NF,NFK,574
164
+ MK,MKD,807
165
+ MP,MNP,580
166
+ NO,NOR,578
167
+ OM,OMN,512
168
+ PK,PAK,586
169
+ PW,PLW,585
170
+ PS,PSE,275
171
+ PA,PAN,591
172
+ PG,PNG,598
173
+ PY,PRY,600
174
+ PE,PER,604
175
+ PH,PHL,608
176
+ PN,PCN,612
177
+ PL,POL,616
178
+ PT,PRT,620
179
+ PR,PRI,630
180
+ QA,QAT,634
181
+ RO,ROU,642
182
+ RU,RUS,643
183
+ RW,RWA,646
184
+ RE,REU,638
185
+ BL,BLM,652
186
+ SH,SHN,654
187
+ KN,KNA,659
188
+ LC,LCA,662
189
+ MF,MAF,663
190
+ PM,SPM,666
191
+ VC,VCT,670
192
+ WS,WSM,882
193
+ SM,SMR,674
194
+ ST,STP,678
195
+ SA,SAU,682
196
+ SN,SEN,686
197
+ RS,SRB,688
198
+ SC,SYC,690
199
+ SL,SLE,694
200
+ SG,SGP,702
201
+ SX,SXM,534
202
+ SK,SVK,703
203
+ SI,SVN,705
204
+ SB,SLB,90
205
+ SO,SOM,706
206
+ ZA,ZAF,710
207
+ GS,SGS,239
208
+ SS,SSD,728
209
+ ES,ESP,724
210
+ LK,LKA,144
211
+ SD,SDN,729
212
+ SR,SUR,740
213
+ SJ,SJM,744
214
+ SE,SWE,752
215
+ CH,CHE,756
216
+ SY,SYR,760
217
+ TW,TWN,158
218
+ TJ,TJK,762
219
+ TZ,TZA,834
220
+ TH,THA,764
221
+ TL,TLS,626
222
+ TG,TGO,768
223
+ TK,TKL,772
224
+ TO,TON,776
225
+ TT,TTO,780
226
+ TN,TUN,788
227
+ TM,TKM,795
228
+ TC,TCA,796
229
+ TV,TUV,798
230
+ TR,TUR,792
231
+ UG,UGA,800
232
+ UA,UKR,804
233
+ AE,ARE,784
234
+ GB,GBR,826
235
+ UM,UMI,581
236
+ US,USA,840
237
+ UY,URY,858
238
+ UZ,UZB,860
239
+ VU,VUT,548
240
+ VE,VEN,862
241
+ VN,VNM,704
242
+ VG,VGB,92
243
+ VI,VIR,850
244
+ WF,WLF,876
245
+ EH,ESH,732
246
+ YE,YEM,887
247
+ ZM,ZMB,894
248
+ ZW,ZWE,716
249
+ AX,ALA,248
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- I18nCountries::VERSION = "0.1.2"
3
+ I18nCountries::VERSION = "0.1.3"
@@ -1,15 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+ require 'csv'
4
5
 
5
6
  class I18nCountries
6
- attr_reader :countries
7
+ attr_reader :countries, :codes
7
8
 
8
9
  def initialize()
9
10
  @countries ||= {}
10
- yaml_files.each_pair do |locale, file_path|
11
+ @codes ||= {}
12
+ localized_country_files.each_pair do |locale, file_path|
11
13
  @countries[locale] = Psych.load_file(file_path)
12
14
  end
15
+ CSV.foreach(codes_file) do |row|
16
+ @codes[row[0]] = { 'a3' => row[1], 'numeric' => row[2].to_i }
17
+ end
13
18
  end
14
19
 
15
20
  def locales
@@ -17,11 +22,16 @@ class I18nCountries
17
22
  end
18
23
 
19
24
  private
20
- def yaml_files()
25
+ def localized_country_files()
21
26
  dirs = Dir.entries(File.join(my_dir, 'data')) - %w(. ..)
27
+ dirs = dirs.select { |dir| File.directory?(File.join(my_dir, 'data', dir)) }
22
28
  dirs.to_h { |dir| [dir, File.join(my_dir, 'data', dir, 'country.yaml')] }
23
29
  end
24
30
 
31
+ def codes_file()
32
+ file = File.join(my_dir, 'data', 'codes.csv')
33
+ end
34
+
25
35
  def my_dir()
26
36
  __dir__
27
37
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_countries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Brown
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-24 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: byebug
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Generates a hash of mulitilingual country names for 628 locales.
28
14
  email:
29
15
  - steve@zergsoft.com
@@ -40,6 +26,7 @@ files:
40
26
  - LICENSE.txt
41
27
  - README.md
42
28
  - Rakefile
29
+ - i18n_countries.gemspec
43
30
  - lib/data/af/country.yaml
44
31
  - lib/data/af_NA/country.yaml
45
32
  - lib/data/af_ZA/country.yaml
@@ -113,6 +100,7 @@ files:
113
100
  - lib/data/ca_IT/country.yaml
114
101
  - lib/data/ce/country.yaml
115
102
  - lib/data/ce_RU/country.yaml
103
+ - lib/data/codes.csv
116
104
  - lib/data/cs/country.yaml
117
105
  - lib/data/cs_CZ/country.yaml
118
106
  - lib/data/cy/country.yaml