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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5095e321840b32d7b7b213a092f6ba6c922f5d02
4
- data.tar.gz: 6e1d58d243088cdc207d049e7fe0d21df21cd8c8
3
+ metadata.gz: 780e6ea8c874d6fd34987d4f48e8d8447a81c5e7
4
+ data.tar.gz: 6f170ca9aa9fe7b459c7df3cc2d03e74eccb805e
5
5
  SHA512:
6
- metadata.gz: 9e0334d0660c6524e78a5fb5676768c3fe836e40e67cc155f6e1a346b52f0598628cbba2eab64b95d8e090200a9cce74b60e3bdf1d80d6c03d3a1c774a3ae7c8
7
- data.tar.gz: 37297a94a08257eb80fe69f2fa14ad4689f4fce2e579ae70c2714c03e9a34370efdbb4ea540503a2fdb9fc7aec20d8a2af903d2de122ece3e17a607c483b352e
6
+ metadata.gz: e3a441dbcac8f4528a0373bed2df5903ff856e58e24e8f893e73775a6caaae7d731f600a171e87d180041b0d387570edb52eaa4d59e8505da731a9f90bbbce07
7
+ data.tar.gz: 68fd1ac5eef528aadbc658e58d1f33ea558904a64c3cffa30ebbbe55b9850a1845c8b20c1219b68977c11e8de3e93aae1341b0433032396c9dc23a99d9975c7d
@@ -1,3 +1,4 @@
1
+ require 'i18n_country_translations/locale_files_pattern_generator'
1
2
  require 'i18n_country_translations/railtie'
2
3
 
3
4
  module I18nCountryTranslations
@@ -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
- pattern = pattern_from app.config.i18n.available_locales
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
@@ -1,3 +1,3 @@
1
1
  module I18nCountryTranslations
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  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: جزيرة مان
@@ -15,7 +15,7 @@ ko:
15
15
  AR: 아르헨티나
16
16
  AS: 아메리칸 사모아
17
17
  AT: 오스트리아
18
- AU: 오스트레일리아
18
+ AU: 호주
19
19
  AW: 아루바
20
20
  AX: 올란드 제도
21
21
  AZ: 아제르바이잔
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.3
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: 2015-10-19 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
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: '3.0'
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: '3.0'
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.4.8
331
+ rubygems_version: 2.5.1
331
332
  signing_key:
332
333
  specification_version: 4
333
334
  summary: I18n Country Translations