i18n-country-translations 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n_country_translations.rb +1 -0
- data/lib/i18n_country_translations/locale_files_pattern_generator.rb +32 -0
- data/lib/i18n_country_translations/railtie.rb +2 -7
- data/lib/i18n_country_translations/version.rb +1 -1
- data/rails/locale/iso_639-1/ar.yml +2 -2
- data/rails/locale/iso_639-1/ko.yml +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 780e6ea8c874d6fd34987d4f48e8d8447a81c5e7
|
4
|
+
data.tar.gz: 6f170ca9aa9fe7b459c7df3cc2d03e74eccb805e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3a441dbcac8f4528a0373bed2df5903ff856e58e24e8f893e73775a6caaae7d731f600a171e87d180041b0d387570edb52eaa4d59e8505da731a9f90bbbce07
|
7
|
+
data.tar.gz: 68fd1ac5eef528aadbc658e58d1f33ea558904a64c3cffa30ebbbe55b9850a1845c8b20c1219b68977c11e8de3e93aae1341b0433032396c9dc23a99d9975c7d
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module I18nCountryTranslations
|
2
|
+
|
3
|
+
# Generates patterns for locale files, bases on a list of supported locales
|
4
|
+
class LocaleFilesPatternGenerator
|
5
|
+
|
6
|
+
attr_reader :base_pattern, :extension
|
7
|
+
|
8
|
+
def initialize(base_pattern, extension = '.yml')
|
9
|
+
@base_pattern = base_pattern
|
10
|
+
@extension = extension
|
11
|
+
end
|
12
|
+
|
13
|
+
# Generates a glob file pattern for the specified list of locales (i.e. IETF language tags)
|
14
|
+
def pattern_from(locales)
|
15
|
+
locales = Array(locales || [])
|
16
|
+
locales = locales.map { |locale| subpatterns_from locale }.flatten
|
17
|
+
pattern = locales.blank? ? '*' : "{#{locales.join ','}}"
|
18
|
+
"#{base_pattern}#{pattern}#{extension}"
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
# Generates subpatterns for the specified locale (i.e. IETF language tag).
|
24
|
+
# Subpatterns are all more generic variations of a locale.
|
25
|
+
# E.g. subpatterns for en-US are en-US and en. Subpatterns for az-Latn-IR are az-Latn-IR, az-Latn and az
|
26
|
+
def subpatterns_from(locale)
|
27
|
+
parts = locale.to_s.split('-')
|
28
|
+
parts.map.with_index { |part,index| parts[0..index].join('-') }
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -4,9 +4,8 @@ module I18nCountryTranslations
|
|
4
4
|
class Railtie < ::Rails::Railtie #:nodoc:
|
5
5
|
initializer 'i18n-country-translations' do |app|
|
6
6
|
I18nCountryTranslations::Railtie.instance_eval do
|
7
|
-
|
8
|
-
|
9
|
-
add("rails/locale/**/#{pattern}.yml")
|
7
|
+
generator = LocaleFilesPatternGenerator.new('rails/locale/**/')
|
8
|
+
add generator.pattern_from app.config.i18n.available_locales
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
@@ -17,9 +16,5 @@ module I18nCountryTranslations
|
|
17
16
|
I18n.load_path.concat(files)
|
18
17
|
end
|
19
18
|
|
20
|
-
def self.pattern_from(args)
|
21
|
-
array = Array(args || [])
|
22
|
-
array.blank? ? '*' : "{#{array.join ','}}"
|
23
|
-
end
|
24
19
|
end
|
25
20
|
end
|
@@ -94,7 +94,7 @@ ar:
|
|
94
94
|
GM: غامبيا
|
95
95
|
GN: غينيا
|
96
96
|
GP: جوادلوب
|
97
|
-
GQ: غينيا
|
97
|
+
GQ: غينيا الاستوائية
|
98
98
|
GR: اليونان
|
99
99
|
GS: جورجيا الجنوبية وجزر ساندويتش الجنوبية
|
100
100
|
GT: غواتيمالا
|
@@ -108,7 +108,7 @@ ar:
|
|
108
108
|
HT: هايتي
|
109
109
|
HU: هنغاريا
|
110
110
|
IC: جزر الكناري
|
111
|
-
ID:
|
111
|
+
ID: إندونيسيا
|
112
112
|
IE: أيرلندا
|
113
113
|
IL: إسرائيل
|
114
114
|
IM: جزيرة مان
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-country-translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian McQuay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/i18n-country-translations.rb
|
137
137
|
- lib/i18n_country_translations.rb
|
138
138
|
- lib/i18n_country_translations/import_two_letter_codes.rb
|
139
|
+
- lib/i18n_country_translations/locale_files_pattern_generator.rb
|
139
140
|
- lib/i18n_country_translations/railtie.rb
|
140
141
|
- lib/i18n_country_translations/version.rb
|
141
142
|
- lib/tasks/i18n-country-translations_tasks.rake
|
@@ -327,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
328
|
version: '0'
|
328
329
|
requirements: []
|
329
330
|
rubyforge_project:
|
330
|
-
rubygems_version: 2.
|
331
|
+
rubygems_version: 2.5.1
|
331
332
|
signing_key:
|
332
333
|
specification_version: 4
|
333
334
|
summary: I18n Country Translations
|