i18n_data 0.17.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/cache/file_data_provider/countries-AB.txt +3 -3
  3. data/cache/file_data_provider/countries-AF.txt +3 -3
  4. data/cache/file_data_provider/countries-AK.txt +3 -3
  5. data/cache/file_data_provider/countries-AM.txt +3 -3
  6. data/cache/file_data_provider/countries-AN.txt +3 -3
  7. data/cache/file_data_provider/countries-AR.txt +3 -3
  8. data/cache/file_data_provider/countries-AS.txt +3 -3
  9. data/cache/file_data_provider/countries-AY.txt +3 -3
  10. data/cache/file_data_provider/countries-AZ.txt +4 -4
  11. data/cache/file_data_provider/countries-BA.txt +3 -3
  12. data/cache/file_data_provider/countries-BE.txt +6 -6
  13. data/cache/file_data_provider/countries-BG.txt +27 -27
  14. data/cache/file_data_provider/countries-BI.txt +3 -3
  15. data/cache/file_data_provider/countries-BN.txt +3 -3
  16. data/cache/file_data_provider/countries-BN_IN.txt +6 -6
  17. data/cache/file_data_provider/countries-BR.txt +3 -3
  18. data/cache/file_data_provider/countries-BS.txt +3 -3
  19. data/cache/file_data_provider/countries-CA.txt +31 -31
  20. data/cache/file_data_provider/countries-CE.txt +3 -3
  21. data/cache/file_data_provider/countries-CH.txt +3 -3
  22. data/cache/file_data_provider/countries-CS.txt +6 -6
  23. data/cache/file_data_provider/countries-CV.txt +3 -3
  24. data/cache/file_data_provider/countries-CY.txt +33 -33
  25. data/cache/file_data_provider/countries-DA.txt +3 -3
  26. data/cache/file_data_provider/countries-DE.txt +5 -5
  27. data/cache/file_data_provider/countries-DV.txt +3 -3
  28. data/cache/file_data_provider/countries-DZ.txt +3 -3
  29. data/cache/file_data_provider/countries-EE.txt +3 -3
  30. data/cache/file_data_provider/countries-EL.txt +3 -3
  31. data/cache/file_data_provider/countries-EN.txt +3 -3
  32. data/cache/file_data_provider/countries-EO.txt +3 -3
  33. data/cache/file_data_provider/countries-ES.txt +6 -6
  34. data/cache/file_data_provider/countries-ET.txt +2 -2
  35. data/cache/file_data_provider/countries-EU.txt +3 -3
  36. data/cache/file_data_provider/countries-FA.txt +3 -3
  37. data/cache/file_data_provider/countries-FF.txt +3 -3
  38. data/cache/file_data_provider/countries-FI.txt +2 -2
  39. data/cache/file_data_provider/countries-FO.txt +3 -3
  40. data/cache/file_data_provider/countries-FR.txt +11 -11
  41. data/cache/file_data_provider/countries-FY.txt +3 -3
  42. data/cache/file_data_provider/countries-GA.txt +3 -3
  43. data/cache/file_data_provider/countries-GL.txt +3 -3
  44. data/cache/file_data_provider/countries-GN.txt +3 -3
  45. data/cache/file_data_provider/countries-GU.txt +3 -3
  46. data/cache/file_data_provider/countries-GV.txt +3 -3
  47. data/cache/file_data_provider/countries-HA.txt +3 -3
  48. data/cache/file_data_provider/countries-HE.txt +2 -2
  49. data/cache/file_data_provider/countries-HI.txt +62 -62
  50. data/cache/file_data_provider/countries-HR.txt +4 -4
  51. data/cache/file_data_provider/countries-HT.txt +3 -3
  52. data/cache/file_data_provider/countries-HU.txt +6 -6
  53. data/cache/file_data_provider/countries-HY.txt +61 -61
  54. data/cache/file_data_provider/countries-IA.txt +2 -2
  55. data/cache/file_data_provider/countries-ID.txt +5 -5
  56. data/cache/file_data_provider/countries-IO.txt +3 -3
  57. data/cache/file_data_provider/countries-IS.txt +3 -3
  58. data/cache/file_data_provider/countries-IT.txt +3 -3
  59. data/cache/file_data_provider/countries-IU.txt +3 -3
  60. data/cache/file_data_provider/countries-JA.txt +7 -7
  61. data/cache/file_data_provider/countries-KA.txt +4 -4
  62. data/cache/file_data_provider/countries-KI.txt +3 -3
  63. data/cache/file_data_provider/countries-KK.txt +11 -11
  64. data/cache/file_data_provider/countries-KL.txt +3 -3
  65. data/cache/file_data_provider/countries-KM.txt +148 -148
  66. data/cache/file_data_provider/countries-KN.txt +3 -3
  67. data/cache/file_data_provider/countries-KO.txt +4 -4
  68. data/cache/file_data_provider/countries-KV.txt +3 -3
  69. data/cache/file_data_provider/countries-KW.txt +3 -3
  70. data/cache/file_data_provider/countries-KY.txt +3 -3
  71. data/cache/file_data_provider/countries-LO.txt +3 -3
  72. data/cache/file_data_provider/countries-LT.txt +14 -14
  73. data/cache/file_data_provider/countries-LV.txt +3 -3
  74. data/cache/file_data_provider/countries-MI.txt +3 -3
  75. data/cache/file_data_provider/countries-MK.txt +3 -3
  76. data/cache/file_data_provider/countries-ML.txt +3 -3
  77. data/cache/file_data_provider/countries-MN.txt +3 -3
  78. data/cache/file_data_provider/countries-MR.txt +3 -3
  79. data/cache/file_data_provider/countries-MS.txt +3 -3
  80. data/cache/file_data_provider/countries-MT.txt +3 -3
  81. data/cache/file_data_provider/countries-MY.txt +3 -3
  82. data/cache/file_data_provider/countries-NA.txt +3 -3
  83. data/cache/file_data_provider/countries-NB.txt +4 -4
  84. data/cache/file_data_provider/countries-NE.txt +3 -3
  85. data/cache/file_data_provider/countries-NL.txt +2 -2
  86. data/cache/file_data_provider/countries-NO.txt +249 -0
  87. data/cache/file_data_provider/countries-NV.txt +3 -3
  88. data/cache/file_data_provider/countries-OC.txt +4 -4
  89. data/cache/file_data_provider/countries-OR.txt +3 -3
  90. data/cache/file_data_provider/countries-PA.txt +6 -6
  91. data/cache/file_data_provider/countries-PI.txt +3 -3
  92. data/cache/file_data_provider/countries-PL.txt +5 -5
  93. data/cache/file_data_provider/countries-PS.txt +3 -3
  94. data/cache/file_data_provider/countries-PT.txt +6 -6
  95. data/cache/file_data_provider/countries-PT_BR.txt +4 -4
  96. data/cache/file_data_provider/countries-RO.txt +11 -11
  97. data/cache/file_data_provider/countries-RU.txt +3 -3
  98. data/cache/file_data_provider/countries-RW.txt +3 -3
  99. data/cache/file_data_provider/countries-SC.txt +3 -3
  100. data/cache/file_data_provider/countries-SD.txt +3 -3
  101. data/cache/file_data_provider/countries-SI.txt +3 -3
  102. data/cache/file_data_provider/countries-SK.txt +7 -7
  103. data/cache/file_data_provider/countries-SL.txt +2 -2
  104. data/cache/file_data_provider/countries-SO.txt +3 -3
  105. data/cache/file_data_provider/countries-SQ.txt +6 -6
  106. data/cache/file_data_provider/countries-SR.txt +3 -3
  107. data/cache/file_data_provider/countries-SR@LATIN.txt +3 -3
  108. data/cache/file_data_provider/countries-SV.txt +4 -4
  109. data/cache/file_data_provider/countries-SW.txt +3 -3
  110. data/cache/file_data_provider/countries-TA.txt +100 -100
  111. data/cache/file_data_provider/countries-TE.txt +3 -3
  112. data/cache/file_data_provider/countries-TG.txt +3 -3
  113. data/cache/file_data_provider/countries-TH.txt +3 -3
  114. data/cache/file_data_provider/countries-TI.txt +7 -7
  115. data/cache/file_data_provider/countries-TK.txt +3 -3
  116. data/cache/file_data_provider/countries-TL.txt +3 -3
  117. data/cache/file_data_provider/countries-TR.txt +3 -3
  118. data/cache/file_data_provider/countries-TT.txt +4 -4
  119. data/cache/file_data_provider/countries-UG.txt +3 -3
  120. data/cache/file_data_provider/countries-UK.txt +2 -2
  121. data/cache/file_data_provider/countries-UR.txt +3 -3
  122. data/cache/file_data_provider/countries-UZ.txt +3 -3
  123. data/cache/file_data_provider/countries-VE.txt +3 -3
  124. data/cache/file_data_provider/countries-VI.txt +3 -3
  125. data/cache/file_data_provider/countries-WA.txt +2 -2
  126. data/cache/file_data_provider/countries-WO.txt +3 -3
  127. data/cache/file_data_provider/countries-XH.txt +3 -3
  128. data/cache/file_data_provider/countries-YO.txt +3 -3
  129. data/cache/file_data_provider/countries-ZH_CN.txt +14 -14
  130. data/cache/file_data_provider/countries-ZH_HK.txt +13 -13
  131. data/cache/file_data_provider/countries-ZH_TW.txt +5 -5
  132. data/cache/file_data_provider/countries-ZU.txt +3 -3
  133. data/cache/file_data_provider/languages-CY.txt +29 -29
  134. data/cache/file_data_provider/languages-FR.txt +183 -183
  135. data/cache/file_data_provider/languages-GL.txt +1 -1
  136. data/cache/file_data_provider/languages-HI.txt +69 -69
  137. data/cache/file_data_provider/languages-HR.txt +1 -1
  138. data/cache/file_data_provider/languages-HY.txt +184 -0
  139. data/cache/file_data_provider/languages-IT.txt +9 -9
  140. data/cache/file_data_provider/languages-KA.txt +33 -33
  141. data/cache/file_data_provider/languages-KO.txt +2 -2
  142. data/cache/file_data_provider/languages-LT.txt +5 -5
  143. data/cache/file_data_provider/languages-NO.txt +184 -0
  144. data/cache/file_data_provider/languages-OC.txt +1 -1
  145. data/cache/file_data_provider/languages-RO.txt +184 -184
  146. data/cache/file_data_provider/languages-SQ.txt +177 -177
  147. data/cache/file_data_provider/languages-TA.txt +93 -93
  148. data/cache/file_data_provider/languages-TH.txt +23 -23
  149. data/cache/file_data_provider/languages-ZH_HK.txt +2 -2
  150. data/lib/i18n_data/file_data_provider.rb +15 -15
  151. data/lib/i18n_data/live_data_provider.rb +23 -15
  152. data/lib/i18n_data/version.rb +2 -1
  153. data/lib/i18n_data.rb +9 -9
  154. metadata +7 -4
@@ -1,17 +1,17 @@
1
1
  AA;;อาฟา
2
2
  AB;;แอบกาเซีย
3
- AF;;แอฟริกา
4
- AK;;Akan
3
+ AF;;แอฟริคานส์
4
+ AK;;อะคาน
5
5
  AM;;อัมฮาริก
6
6
  AR;;อารบิก
7
- AN;;Aragonese
7
+ AN;;อารากอน
8
8
  AS;;อัสสมี
9
- AV;;Avaric
9
+ AV;;อาวาริก
10
10
  AE;;อเวสตะ
11
11
  AY;;ไอมารา
12
12
  AZ;;อาเซอร์ไบจาน
13
13
  BA;;บาสช์กีร์
14
- BM;;Bambara
14
+ BM;;บัมบารา
15
15
  BE;;เบลารุส
16
16
  BN;;Bengali
17
17
  BH;;กลุ่มภาษาพิหารี
@@ -25,10 +25,10 @@ CS;;เช็ก
25
25
  CH;;Chamorro
26
26
  CE;;เชเชน
27
27
  CU;;Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
28
- CV;;Chuvash
29
- KW;;Cornish
28
+ CV;;ชูวัช
29
+ KW;;คอร์นิช
30
30
  CO;;Corsican
31
- CR;;Cree
31
+ CR;;ครี
32
32
  CY;;เวลส์
33
33
  DA;;เดนมาร์ก
34
34
  DE;;เยอรมัน
@@ -39,19 +39,19 @@ EN;;อังกฤษ
39
39
  EO;;เอสเปอรันโต
40
40
  ET;;เอสโตเนีย
41
41
  EU;;แบ็ซค์
42
- EE;;Ewe
42
+ EE;;เอเว
43
43
  FO;;แฟโร
44
44
  FA;;เปอร์เซีย
45
45
  FJ;;ฟิจิ
46
46
  FI;;ฟินแลนด์
47
47
  FR;;ฝรั่งเศส
48
- FY;;Western Frisian
48
+ FY;;ฟรีเชียตะวันตก
49
49
  FF;;Fulah
50
- GD;;Gaelic; Scottish Gaelic
50
+ GD;;เกลิก; เกลิกสก็อต
51
51
  GA;;ไอริช
52
52
  GL;;กาลิเซีย
53
53
  GV;;Manx
54
- GN;;Guarani
54
+ GN;;กวารานี
55
55
  GU;;คุชราตี
56
56
  HT;;เฮติ; ลูกผสมเฮติ
57
57
  HA;;โฮซา
@@ -74,17 +74,17 @@ IS;;ไอซ์แลนด์
74
74
  IT;;อิตาลี
75
75
  JV;;ชวา
76
76
  JA;;ญี่ปุ่น
77
- KL;;Kalaallisut; Greenlandic
77
+ KL;;กะลาลลิซุต; กรีนแลนด์
78
78
  KN;;กัณณาท
79
79
  KS;;กัศมีรี
80
80
  KA;;จอร์เจีย
81
81
  KR;;Kanuri
82
82
  KK;;คาซัคสถาน
83
83
  KM;;เขมรกลาง
84
- KI;;Kikuyu; Gikuyu
84
+ KI;;คิคูยู; กิคูยู
85
85
  RW;;คินยารวันดา
86
- KY;;คีร์กีซสถาน
87
- KV;;Komi
86
+ KY;;คีร์กีซ
87
+ KV;;โคมิ
88
88
  KG;;คองโก
89
89
  KO;;เกาหลี
90
90
  KJ;;Kuanyama; Kwanyama
@@ -97,7 +97,7 @@ LN;;ลิงกาลา
97
97
  LT;;ลิทัวเนีย
98
98
  LB;;ลักเซมเบิร์ก
99
99
  LU;;Luba-Katanga
100
- LG;;Ganda
100
+ LG;;แกนดา
101
101
  MH;;มาร์แชลล์
102
102
  ML;;มลยาฬัม
103
103
  MR;;มราฐี
@@ -110,19 +110,19 @@ MS;;มลายู
110
110
  MY;;พม่า
111
111
  NA;;นาอูรู
112
112
  NV;;นาวาโฮ
113
- NR;;Ndebele, South; South Ndebele
114
- ND;;Ndebele, North; North Ndebele
113
+ NR;;เอ็นดีเบลีใต้
114
+ ND;;เอ็นดีเบลีเหนือ
115
115
  NG;;Ndonga
116
116
  NE;;เนปาล
117
117
  NL;;Dutch; Flemish
118
118
  NN;;นอร์เวย์ (นีนอร์สก์)
119
119
  NB;;นอร์เวย์ (บุคมอล)
120
120
  NO;;นอร์เวย์
121
- NY;;Chichewa; Chewa; Nyanja
121
+ NY;;ชิเชวา; เชวา; นยานจา
122
122
  OC;;Occitan (post 1500); Provençal
123
123
  OJ;;โอจิบเว
124
124
  OR;;โอริยา
125
- OM;;โอโรโม
125
+ OM;;ออโรโม
126
126
  OS;;Ossetian; Ossetic
127
127
  PA;;ปัญจาบี
128
128
  PI;;บาลี
@@ -139,7 +139,7 @@ SA;;สันสกฤต
139
139
  SI;;สิงหล
140
140
  SK;;สโลวัก
141
141
  SL;;สโลวีเนีย
142
- SE;;ซามิเหนือ
142
+ SE;;ซามีเหนือ
143
143
  SM;;ซามัว
144
144
  SN;;Shona
145
145
  SD;;สินธี
@@ -171,7 +171,7 @@ UG;;อุยกูร์
171
171
  UK;;ยูเครน
172
172
  UR;;อูรดู
173
173
  UZ;;อุซเบกิสถาน
174
- VE;;Venda
174
+ VE;;เวนดา
175
175
  VI;;เวียดนาม
176
176
  VO;;Volapük
177
177
  WA;;วอลลูน
@@ -116,8 +116,8 @@ NG;;恩敦加語
116
116
  NE;;尼泊爾語
117
117
  NL;;荷蘭語
118
118
  NN;;新挪威語
119
- NB;;Bokmål, Norwegian; Norwegian Bokmål
120
- NO;;書面挪威語
119
+ NB;;書面挪威語
120
+ NO;;挪威語
121
121
  NY;;尼揚賈語
122
122
  OC;;奧克西坦語 (1500 之後);普羅旺斯語
123
123
  OJ;;奧杰布瓦語
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module I18nData
2
3
  module FileDataProvider
3
4
  require 'fileutils'
@@ -6,24 +7,25 @@ module I18nData
6
7
  extend self
7
8
 
8
9
  def codes(type, language_code)
9
- unless data = read_from_file(cache_file_for(type, language_code))
10
+ unless (data = read_from_file(cache_file_for(type, language_code)))
10
11
  raise NoTranslationAvailable, "#{type}-#{language_code}"
11
12
  end
12
13
  data
13
14
  end
14
15
 
15
16
  def write_cache(provider)
16
- languages = provider.codes(:languages, 'EN').keys + ['zh_CN', 'zh_TW', 'zh_HK', 'bn_IN', 'pt_BR', 'sr@latin']
17
+ languages = provider.codes(
18
+ :languages,
19
+ 'EN'
20
+ ).keys + ['zh_CN', 'zh_TW', 'zh_HK', 'bn_IN', 'pt_BR', 'sr@latin', 'nb_NO']
17
21
  languages.map do |language_code|
18
22
  [:languages, :countries].each do |type|
19
- begin
20
- data = provider.send(:codes, type, language_code)
21
- write_to_file(data, cache_file_for(type, language_code))
22
- rescue NoTranslationAvailable
23
- $stderr.puts "No translation available for #{type} #{language_code}" if $DEBUG
24
- rescue AccessDenied
25
- $stderr.puts "Access denied for #{type} #{language_code}"
26
- end
23
+ data = provider.send(:codes, type, language_code)
24
+ write_to_file(data, cache_file_for(type, language_code))
25
+ rescue NoTranslationAvailable
26
+ warn "No translation available for #{type} #{language_code}" if $DEBUG
27
+ rescue AccessDenied
28
+ warn "Access denied for #{type} #{language_code}"
27
29
  end
28
30
  end
29
31
  end
@@ -33,7 +35,7 @@ module I18nData
33
35
  def read_from_file(file)
34
36
  return nil unless File.exist?(file)
35
37
  data = {}
36
- File.readlines(file, :encoding => 'utf-8').each do |line|
38
+ File.readlines(file, encoding: 'utf-8').each do |line|
37
39
  code, translation = line.strip.split(DATA_SEPARATOR, 2)
38
40
  data[code] = translation
39
41
  end
@@ -43,12 +45,10 @@ module I18nData
43
45
  def write_to_file(data, file)
44
46
  return if data.empty?
45
47
  FileUtils.mkdir_p File.dirname(file)
46
- File.open(file,'w') do |f|
47
- f.write data.map{|code, translation| "#{code}#{DATA_SEPARATOR}#{translation}" } * "\n"
48
- end
48
+ File.write(file, data.map { |code, translation| "#{code}#{DATA_SEPARATOR}#{translation}" } * "\n")
49
49
  end
50
50
 
51
- def cache_file_for(type,language_code)
51
+ def cache_file_for(type, language_code)
52
52
  file = "#{type}-#{language_code.sub('-', '_').upcase}"
53
53
  File.join(File.dirname(__FILE__), '..', '..', 'cache', 'file_data_provider', "#{file}.txt")
54
54
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json'
2
3
  require 'simple_po_parser'
3
4
 
@@ -7,14 +8,14 @@ module I18nData
7
8
  extend self
8
9
 
9
10
  JSON_CODES = {
10
- :countries => 'data/iso_3166-1.json',
11
- :languages => 'data/iso_639-2.json'
12
- }
11
+ countries: 'data/iso_3166-1.json',
12
+ languages: 'data/iso_639-2.json'
13
+ }.freeze
13
14
 
14
15
  TRANSLATIONS = {
15
- :countries => 'iso_3166-1/',
16
- :languages => 'iso_639-2/'
17
- }
16
+ countries: 'iso_3166-1/',
17
+ languages: 'iso_639-2/'
18
+ }.freeze
18
19
  REPO = "https://salsa.debian.org/iso-codes-team/iso-codes.git"
19
20
  CLONE_DEST = "/tmp/i18n_data_iso_clone"
20
21
 
@@ -34,7 +35,7 @@ module I18nData
34
35
  raise unless $?.success?
35
36
  end
36
37
 
37
- private
38
+ private
38
39
 
39
40
  def ensure_checkout
40
41
  unless File.exist?(CLONE_DEST)
@@ -46,10 +47,8 @@ module I18nData
46
47
  def translated(type, language_code)
47
48
  @translated ||= {}
48
49
 
49
- @translated["#{type}_#{language_code}"] ||= begin
50
- Hash[send("alpha_codes_for_#{type}").map do |alpha2, alpha3|
51
- [alpha2, translate(type, alpha3, language_code) || fallback_name(type, alpha3)]
52
- end]
50
+ @translated["#{type}_#{language_code}"] ||= send("alpha_codes_for_#{type}").transform_values do |alpha3|
51
+ translate(type, alpha3, language_code) || fallback_name(type, alpha3)
53
52
  end
54
53
  end
55
54
 
@@ -61,14 +60,20 @@ module I18nData
61
60
  def translations(type, language_code)
62
61
  @translations ||= {}
63
62
  @translations["#{type}_#{language_code}"] ||= begin
63
+ # FOO_BAR -> foo_BAR
64
64
  code = language_code.split("_")
65
65
  code[0].downcase!
66
66
  code = code.join("_")
67
67
 
68
68
  begin
69
69
  file_path = "#{CLONE_DEST}/#{TRANSLATIONS[type]}#{code}.po"
70
+
71
+ # norwegian has 2 versions (nb and nn), but only nb is supported, so we have to pick that
72
+ # https://salsa.debian.org/iso-codes-team/iso-codes/-/tree/main/iso_639-2
73
+ file_path = file_path.sub("/no.po", "/nb.po").sub("/nb.po", "/nb_no.po")
74
+
70
75
  data = SimplePoParser.parse(file_path)
71
- data = data[1..-1] # Remove the initial info block in the .po file
76
+ data = data[1..] # Remove the initial info block in the .po file
72
77
 
73
78
  # Prefer the "Common name for" blocks, but fallback to "Name for" blocks
74
79
  common_names = get_po_data(data, 'Common name for')
@@ -76,7 +81,10 @@ module I18nData
76
81
 
77
82
  fallback_names.merge(common_names)
78
83
  rescue Errno::ENOENT
79
- raise NoTranslationAvailable, "for #{type} and language code = #{code} (#{$!})"
84
+ raise(
85
+ NoTranslationAvailable,
86
+ "No translation available for #{type} and language code = #{code} (#{$!})"
87
+ )
80
88
  end
81
89
  end
82
90
  end
@@ -90,7 +98,7 @@ module I18nData
90
98
  # Maps over the alpha3 country code in the 'extracted_comment'
91
99
  # Eg: "Name for GBR"
92
100
  po_entries.map.with_object({}) do |t, translations|
93
- alpha3 = t[:extracted_comment][-3..-1].upcase
101
+ alpha3 = t[:extracted_comment][-3..].upcase
94
102
  translation = t[:msgstr]
95
103
  translations[alpha3] = translation.is_a?(Array) ? translation.join : translation
96
104
  end
@@ -118,7 +126,7 @@ module I18nData
118
126
  json(:languages)['639-2'].each do |entry|
119
127
  name = entry['name'].to_s
120
128
  code = entry['alpha_2'].to_s.upcase
121
- next if code.empty? or name.empty?
129
+ next if code.empty? || name.empty?
122
130
  codes[code] = name
123
131
  end
124
132
  codes
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module I18nData
2
- VERSION = Version = "0.17.1"
3
+ VERSION = Version = "1.1.0" # rubocop:disable Naming/ConstantName
3
4
  end
data/lib/i18n_data.rb CHANGED
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'i18n_data/version'
2
3
 
3
4
  module I18nData
4
-
5
5
  class BaseException < StandardError
6
6
  def to_s
7
7
  "#{self.class} -- #{super}"
@@ -13,13 +13,13 @@ module I18nData
13
13
  class Unknown < BaseException; end
14
14
 
15
15
  class << self
16
- def languages(language_code='EN')
16
+ def languages(language_code = 'EN')
17
17
  fetch :languages, language_code do
18
18
  data_provider.codes(:languages, normal_to_region_code(language_code.to_s.upcase))
19
19
  end
20
20
  end
21
21
 
22
- def countries(language_code='EN')
22
+ def countries(language_code = 'EN')
23
23
  fetch :countries, language_code do
24
24
  data_provider.codes(:countries, normal_to_region_code(language_code.to_s.upcase))
25
25
  end
@@ -34,10 +34,10 @@ module I18nData
34
34
  end
35
35
 
36
36
  def data_provider
37
- @data_provider ||= (
37
+ @data_provider ||= begin
38
38
  require 'i18n_data/file_data_provider'
39
39
  FileDataProvider
40
- )
40
+ end
41
41
  end
42
42
 
43
43
  def data_provider=(provider)
@@ -57,7 +57,7 @@ module I18nData
57
57
  def normal_to_region_code(normal)
58
58
  {
59
59
  "ZH" => "zh_CN",
60
- "BN" => "bn_IN",
60
+ "BN" => "bn_IN"
61
61
  }[normal] || normal
62
62
  end
63
63
 
@@ -65,7 +65,7 @@ module I18nData
65
65
  search = search.strip
66
66
 
67
67
  # common languages first <-> faster in majority of cases
68
- language_codes = ['EN','ES','FR','DE','ZH'] | available_language_codes
68
+ language_codes = ['EN', 'ES', 'FR', 'DE', 'ZH'] | available_language_codes
69
69
 
70
70
  language_codes.each do |language_code|
71
71
  options =
@@ -88,8 +88,8 @@ module I18nData
88
88
  # NOTE: this is not perfect since the used provider might have more or less languages available
89
89
  # but it's better than just using the available english language codes
90
90
  def available_language_codes
91
- @available_languges ||= begin
92
- files = Dir[File.expand_path("../../cache/file_data_provider/languages-*", __FILE__)]
91
+ @available_language_codes ||= begin
92
+ files = Dir[File.expand_path('../cache/file_data_provider/languages-*', __dir__)]
93
93
  files.map! { |f| f[/languages-(.*)\./, 1] }
94
94
  end
95
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-16 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_po_parser
@@ -115,6 +115,7 @@ files:
115
115
  - cache/file_data_provider/countries-NE.txt
116
116
  - cache/file_data_provider/countries-NL.txt
117
117
  - cache/file_data_provider/countries-NN.txt
118
+ - cache/file_data_provider/countries-NO.txt
118
119
  - cache/file_data_provider/countries-NV.txt
119
120
  - cache/file_data_provider/countries-OC.txt
120
121
  - cache/file_data_provider/countries-OR.txt
@@ -192,6 +193,7 @@ files:
192
193
  - cache/file_data_provider/languages-HI.txt
193
194
  - cache/file_data_provider/languages-HR.txt
194
195
  - cache/file_data_provider/languages-HU.txt
196
+ - cache/file_data_provider/languages-HY.txt
195
197
  - cache/file_data_provider/languages-ID.txt
196
198
  - cache/file_data_provider/languages-IS.txt
197
199
  - cache/file_data_provider/languages-IT.txt
@@ -211,6 +213,7 @@ files:
211
213
  - cache/file_data_provider/languages-NB.txt
212
214
  - cache/file_data_provider/languages-NL.txt
213
215
  - cache/file_data_provider/languages-NN.txt
216
+ - cache/file_data_provider/languages-NO.txt
214
217
  - cache/file_data_provider/languages-OC.txt
215
218
  - cache/file_data_provider/languages-OR.txt
216
219
  - cache/file_data_provider/languages-PA.txt
@@ -260,14 +263,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
263
  requirements:
261
264
  - - ">="
262
265
  - !ruby/object:Gem::Version
263
- version: 2.5.0
266
+ version: 3.0.0
264
267
  required_rubygems_version: !ruby/object:Gem::Requirement
265
268
  requirements:
266
269
  - - ">="
267
270
  - !ruby/object:Gem::Version
268
271
  version: '0'
269
272
  requirements: []
270
- rubygems_version: 3.3.3
273
+ rubygems_version: 3.4.10
271
274
  signing_key:
272
275
  specification_version: 4
273
276
  summary: country/language names and 2-letter-code pairs, in 85 languages