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.
- checksums.yaml +4 -4
- data/cache/file_data_provider/countries-AB.txt +3 -3
- data/cache/file_data_provider/countries-AF.txt +3 -3
- data/cache/file_data_provider/countries-AK.txt +3 -3
- data/cache/file_data_provider/countries-AM.txt +3 -3
- data/cache/file_data_provider/countries-AN.txt +3 -3
- data/cache/file_data_provider/countries-AR.txt +3 -3
- data/cache/file_data_provider/countries-AS.txt +3 -3
- data/cache/file_data_provider/countries-AY.txt +3 -3
- data/cache/file_data_provider/countries-AZ.txt +4 -4
- data/cache/file_data_provider/countries-BA.txt +3 -3
- data/cache/file_data_provider/countries-BE.txt +6 -6
- data/cache/file_data_provider/countries-BG.txt +27 -27
- data/cache/file_data_provider/countries-BI.txt +3 -3
- data/cache/file_data_provider/countries-BN.txt +3 -3
- data/cache/file_data_provider/countries-BN_IN.txt +6 -6
- data/cache/file_data_provider/countries-BR.txt +3 -3
- data/cache/file_data_provider/countries-BS.txt +3 -3
- data/cache/file_data_provider/countries-CA.txt +31 -31
- data/cache/file_data_provider/countries-CE.txt +3 -3
- data/cache/file_data_provider/countries-CH.txt +3 -3
- data/cache/file_data_provider/countries-CS.txt +6 -6
- data/cache/file_data_provider/countries-CV.txt +3 -3
- data/cache/file_data_provider/countries-CY.txt +33 -33
- data/cache/file_data_provider/countries-DA.txt +3 -3
- data/cache/file_data_provider/countries-DE.txt +5 -5
- data/cache/file_data_provider/countries-DV.txt +3 -3
- data/cache/file_data_provider/countries-DZ.txt +3 -3
- data/cache/file_data_provider/countries-EE.txt +3 -3
- data/cache/file_data_provider/countries-EL.txt +3 -3
- data/cache/file_data_provider/countries-EN.txt +3 -3
- data/cache/file_data_provider/countries-EO.txt +3 -3
- data/cache/file_data_provider/countries-ES.txt +6 -6
- data/cache/file_data_provider/countries-ET.txt +2 -2
- data/cache/file_data_provider/countries-EU.txt +3 -3
- data/cache/file_data_provider/countries-FA.txt +3 -3
- data/cache/file_data_provider/countries-FF.txt +3 -3
- data/cache/file_data_provider/countries-FI.txt +2 -2
- data/cache/file_data_provider/countries-FO.txt +3 -3
- data/cache/file_data_provider/countries-FR.txt +11 -11
- data/cache/file_data_provider/countries-FY.txt +3 -3
- data/cache/file_data_provider/countries-GA.txt +3 -3
- data/cache/file_data_provider/countries-GL.txt +3 -3
- data/cache/file_data_provider/countries-GN.txt +3 -3
- data/cache/file_data_provider/countries-GU.txt +3 -3
- data/cache/file_data_provider/countries-GV.txt +3 -3
- data/cache/file_data_provider/countries-HA.txt +3 -3
- data/cache/file_data_provider/countries-HE.txt +2 -2
- data/cache/file_data_provider/countries-HI.txt +62 -62
- data/cache/file_data_provider/countries-HR.txt +4 -4
- data/cache/file_data_provider/countries-HT.txt +3 -3
- data/cache/file_data_provider/countries-HU.txt +6 -6
- data/cache/file_data_provider/countries-HY.txt +61 -61
- data/cache/file_data_provider/countries-IA.txt +2 -2
- data/cache/file_data_provider/countries-ID.txt +5 -5
- data/cache/file_data_provider/countries-IO.txt +3 -3
- data/cache/file_data_provider/countries-IS.txt +3 -3
- data/cache/file_data_provider/countries-IT.txt +3 -3
- data/cache/file_data_provider/countries-IU.txt +3 -3
- data/cache/file_data_provider/countries-JA.txt +7 -7
- data/cache/file_data_provider/countries-KA.txt +4 -4
- data/cache/file_data_provider/countries-KI.txt +3 -3
- data/cache/file_data_provider/countries-KK.txt +11 -11
- data/cache/file_data_provider/countries-KL.txt +3 -3
- data/cache/file_data_provider/countries-KM.txt +148 -148
- data/cache/file_data_provider/countries-KN.txt +3 -3
- data/cache/file_data_provider/countries-KO.txt +4 -4
- data/cache/file_data_provider/countries-KV.txt +3 -3
- data/cache/file_data_provider/countries-KW.txt +3 -3
- data/cache/file_data_provider/countries-KY.txt +3 -3
- data/cache/file_data_provider/countries-LO.txt +3 -3
- data/cache/file_data_provider/countries-LT.txt +14 -14
- data/cache/file_data_provider/countries-LV.txt +3 -3
- data/cache/file_data_provider/countries-MI.txt +3 -3
- data/cache/file_data_provider/countries-MK.txt +3 -3
- data/cache/file_data_provider/countries-ML.txt +3 -3
- data/cache/file_data_provider/countries-MN.txt +3 -3
- data/cache/file_data_provider/countries-MR.txt +3 -3
- data/cache/file_data_provider/countries-MS.txt +3 -3
- data/cache/file_data_provider/countries-MT.txt +3 -3
- data/cache/file_data_provider/countries-MY.txt +3 -3
- data/cache/file_data_provider/countries-NA.txt +3 -3
- data/cache/file_data_provider/countries-NB.txt +4 -4
- data/cache/file_data_provider/countries-NE.txt +3 -3
- data/cache/file_data_provider/countries-NL.txt +2 -2
- data/cache/file_data_provider/countries-NO.txt +249 -0
- data/cache/file_data_provider/countries-NV.txt +3 -3
- data/cache/file_data_provider/countries-OC.txt +4 -4
- data/cache/file_data_provider/countries-OR.txt +3 -3
- data/cache/file_data_provider/countries-PA.txt +6 -6
- data/cache/file_data_provider/countries-PI.txt +3 -3
- data/cache/file_data_provider/countries-PL.txt +5 -5
- data/cache/file_data_provider/countries-PS.txt +3 -3
- data/cache/file_data_provider/countries-PT.txt +6 -6
- data/cache/file_data_provider/countries-PT_BR.txt +4 -4
- data/cache/file_data_provider/countries-RO.txt +11 -11
- data/cache/file_data_provider/countries-RU.txt +3 -3
- data/cache/file_data_provider/countries-RW.txt +3 -3
- data/cache/file_data_provider/countries-SC.txt +3 -3
- data/cache/file_data_provider/countries-SD.txt +3 -3
- data/cache/file_data_provider/countries-SI.txt +3 -3
- data/cache/file_data_provider/countries-SK.txt +7 -7
- data/cache/file_data_provider/countries-SL.txt +2 -2
- data/cache/file_data_provider/countries-SO.txt +3 -3
- data/cache/file_data_provider/countries-SQ.txt +6 -6
- data/cache/file_data_provider/countries-SR.txt +3 -3
- data/cache/file_data_provider/countries-SR@LATIN.txt +3 -3
- data/cache/file_data_provider/countries-SV.txt +4 -4
- data/cache/file_data_provider/countries-SW.txt +3 -3
- data/cache/file_data_provider/countries-TA.txt +100 -100
- data/cache/file_data_provider/countries-TE.txt +3 -3
- data/cache/file_data_provider/countries-TG.txt +3 -3
- data/cache/file_data_provider/countries-TH.txt +3 -3
- data/cache/file_data_provider/countries-TI.txt +7 -7
- data/cache/file_data_provider/countries-TK.txt +3 -3
- data/cache/file_data_provider/countries-TL.txt +3 -3
- data/cache/file_data_provider/countries-TR.txt +3 -3
- data/cache/file_data_provider/countries-TT.txt +4 -4
- data/cache/file_data_provider/countries-UG.txt +3 -3
- data/cache/file_data_provider/countries-UK.txt +2 -2
- data/cache/file_data_provider/countries-UR.txt +3 -3
- data/cache/file_data_provider/countries-UZ.txt +3 -3
- data/cache/file_data_provider/countries-VE.txt +3 -3
- data/cache/file_data_provider/countries-VI.txt +3 -3
- data/cache/file_data_provider/countries-WA.txt +2 -2
- data/cache/file_data_provider/countries-WO.txt +3 -3
- data/cache/file_data_provider/countries-XH.txt +3 -3
- data/cache/file_data_provider/countries-YO.txt +3 -3
- data/cache/file_data_provider/countries-ZH_CN.txt +14 -14
- data/cache/file_data_provider/countries-ZH_HK.txt +13 -13
- data/cache/file_data_provider/countries-ZH_TW.txt +5 -5
- data/cache/file_data_provider/countries-ZU.txt +3 -3
- data/cache/file_data_provider/languages-CY.txt +29 -29
- data/cache/file_data_provider/languages-FR.txt +183 -183
- data/cache/file_data_provider/languages-GL.txt +1 -1
- data/cache/file_data_provider/languages-HI.txt +69 -69
- data/cache/file_data_provider/languages-HR.txt +1 -1
- data/cache/file_data_provider/languages-HY.txt +184 -0
- data/cache/file_data_provider/languages-IT.txt +9 -9
- data/cache/file_data_provider/languages-KA.txt +33 -33
- data/cache/file_data_provider/languages-KO.txt +2 -2
- data/cache/file_data_provider/languages-LT.txt +5 -5
- data/cache/file_data_provider/languages-NO.txt +184 -0
- data/cache/file_data_provider/languages-OC.txt +1 -1
- data/cache/file_data_provider/languages-RO.txt +184 -184
- data/cache/file_data_provider/languages-SQ.txt +177 -177
- data/cache/file_data_provider/languages-TA.txt +93 -93
- data/cache/file_data_provider/languages-TH.txt +23 -23
- data/cache/file_data_provider/languages-ZH_HK.txt +2 -2
- data/lib/i18n_data/file_data_provider.rb +15 -15
- data/lib/i18n_data/live_data_provider.rb +23 -15
- data/lib/i18n_data/version.rb +2 -1
- data/lib/i18n_data.rb +9 -9
- metadata +7 -4
@@ -1,17 +1,17 @@
|
|
1
1
|
AA;;อาฟา
|
2
2
|
AB;;แอบกาเซีย
|
3
|
-
AF
|
4
|
-
AK
|
3
|
+
AF;;แอฟริคานส์
|
4
|
+
AK;;อะคาน
|
5
5
|
AM;;อัมฮาริก
|
6
6
|
AR;;อารบิก
|
7
|
-
AN
|
7
|
+
AN;;อารากอน
|
8
8
|
AS;;อัสสมี
|
9
|
-
AV
|
9
|
+
AV;;อาวาริก
|
10
10
|
AE;;อเวสตะ
|
11
11
|
AY;;ไอมารา
|
12
12
|
AZ;;อาเซอร์ไบจาน
|
13
13
|
BA;;บาสช์กีร์
|
14
|
-
BM
|
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
|
29
|
-
KW
|
28
|
+
CV;;ชูวัช
|
29
|
+
KW;;คอร์นิช
|
30
30
|
CO;;Corsican
|
31
|
-
CR
|
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
|
42
|
+
EE;;เอเว
|
43
43
|
FO;;แฟโร
|
44
44
|
FA;;เปอร์เซีย
|
45
45
|
FJ;;ฟิจิ
|
46
46
|
FI;;ฟินแลนด์
|
47
47
|
FR;;ฝรั่งเศส
|
48
|
-
FY
|
48
|
+
FY;;ฟรีเชียตะวันตก
|
49
49
|
FF;;Fulah
|
50
|
-
GD
|
50
|
+
GD;;เกลิก; เกลิกสก็อต
|
51
51
|
GA;;ไอริช
|
52
52
|
GL;;กาลิเซีย
|
53
53
|
GV;;Manx
|
54
|
-
GN
|
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
|
77
|
+
KL;;กะลาลลิซุต; กรีนแลนด์
|
78
78
|
KN;;กัณณาท
|
79
79
|
KS;;กัศมีรี
|
80
80
|
KA;;จอร์เจีย
|
81
81
|
KR;;Kanuri
|
82
82
|
KK;;คาซัคสถาน
|
83
83
|
KM;;เขมรกลาง
|
84
|
-
KI
|
84
|
+
KI;;คิคูยู; กิคูยู
|
85
85
|
RW;;คินยารวันดา
|
86
|
-
KY
|
87
|
-
KV
|
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
|
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
|
114
|
-
ND
|
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
|
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
|
174
|
+
VE;;เวนดา
|
175
175
|
VI;;เวียดนาม
|
176
176
|
VO;;Volapük
|
177
177
|
WA;;วอลลูน
|
@@ -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(
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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, :
|
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.
|
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
|
-
:
|
11
|
-
:
|
12
|
-
}
|
11
|
+
countries: 'data/iso_3166-1.json',
|
12
|
+
languages: 'data/iso_639-2.json'
|
13
|
+
}.freeze
|
13
14
|
|
14
15
|
TRANSLATIONS = {
|
15
|
-
:
|
16
|
-
:
|
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
|
-
|
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}"] ||=
|
50
|
-
|
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
|
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
|
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
|
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?
|
129
|
+
next if code.empty? || name.empty?
|
122
130
|
codes[code] = name
|
123
131
|
end
|
124
132
|
codes
|
data/lib/i18n_data/version.rb
CHANGED
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
|
-
@
|
92
|
-
files = Dir[File.expand_path(
|
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:
|
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:
|
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:
|
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.
|
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
|