i18n-translators-tools 0.2.5 → 0.2.6

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
  SHA1:
3
- metadata.gz: ec3d676d4b73931620ae4f14fda0380befb5e274
4
- data.tar.gz: 43843b3512f6d599bff966fef2bc9609d15013c1
3
+ metadata.gz: 452d7e32ea216d619c8f0d7213a378f8d7caf788
4
+ data.tar.gz: 3b9958048d471852c791adc90859f810fcaa8e27
5
5
  SHA512:
6
- metadata.gz: f8e345b907b4a1fd80758e97b279b075c68ff9c207844f6fcc0aa9897b281ce28b7bb385cab864eae1db2f5d0a73c97a04e9346d96e9bcc5d5d45bafff730267
7
- data.tar.gz: e371e8bfbf1b3b3b096a17f9f2a6564223bd81af903bd8221b2103efa677a639cffe24c3f99ab0949ca933060081112fe377a3ed672586d8d3b8aa527d9e8e45
6
+ metadata.gz: 4e110260ed071de344d81cba88dbd2ba59658f577851eb84fec77908478345418c0cfd2b2f0500d03ca896979e1ff852dfe26f1c88ce8f9e5d16ffd10995c044
7
+ data.tar.gz: c42e9f56269148c3574a7ad10c9b153fa294e54c45b14a5d0e2500af4d9a3d1a68cbd157bba70cec72d591ee28dfa5c7aa15e6c9cdde748f0f30c331720b3477
@@ -13,9 +13,9 @@ spec = Gem::Specification.new do |s|
13
13
  s.email = "pejuko@gmail.com"
14
14
  s.authors = ["Petr Kovar"]
15
15
  s.name = 'i18n-translators-tools'
16
- s.version = '0.2.5'
16
+ s.version = '0.2.6'
17
17
  s.date = Time.now.strftime("%Y-%m-%d")
18
- s.add_dependency('i18n', '>= 0.5.0')
18
+ s.add_dependency('i18n', '>= 0.7.0')
19
19
  s.add_dependency('ya2yaml')
20
20
  s.require_path = 'lib'
21
21
  s.files = ["bin/i18n-translate", "README.md", "i18n-translators-tools.gemspec", "Rakefile"]
@@ -52,6 +52,9 @@ Functions:
52
52
  * statistics
53
53
 
54
54
  Changelog:
55
+ v0.2.6
56
+ * compatible with i18n 0.7.0
57
+ * make it works with rails 4.2
55
58
  v0.2.5
56
59
  * fix recursive directory scan (-r and --deep options should work now)
57
60
  * enables usage require 'i18n-translators-tools'
@@ -18,22 +18,39 @@ module I18n
18
18
  # wrapper which can work with both format
19
19
  # the simple and the Translator's
20
20
  def translate(locale, key, options = {})
21
- result = super(locale, key, options)
22
- return nil if result.kind_of?(String) and result.empty?
23
- return result unless result.kind_of?(Hash)
24
- return result unless result[:t] or result[:translation] or result[:default]
25
-
26
- tr = result[:translation] || result[:t]
27
- tr = result[:default] if tr.to_s.empty?
28
-
29
- return nil if tr.to_s.empty?
30
-
31
- values = options.except(*RESERVED_KEYS)
21
+ raise InvalidLocale.new(locale) unless locale
22
+ entry = key && lookup(locale, key, options[:scope], options)
23
+ entry = translate_to_i18n(entry)
24
+
25
+ if options.empty?
26
+ entry = resolve(locale, key, entry, options)
27
+ else
28
+ count, default = options.values_at(:count, :default)
29
+ values = options.except(*RESERVED_KEYS)
30
+ entry = entry.nil? && default ?
31
+ default(locale, key, default, options) : resolve(locale, key, entry, options)
32
+ end
33
+
34
+ throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.nil?
35
+ entry = entry.dup if entry.is_a?(String)
36
+
37
+ entry = pluralize(locale, entry, count) if count
38
+ entry = translate_to_i18n(entry) # after pluralization there can be enhanced format
39
+ entry = entry.dup if entry.is_a?(String)
40
+ entry = interpolate(locale, entry, values) if values
41
+
42
+ #throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.to_s.empty?
43
+
44
+ entry
45
+ end
32
46
 
33
- tr = resolve(locale, key, tr, options)
34
- tr = interpolate(locale, tr, values) if values
47
+ protected
35
48
 
36
- tr
49
+ def translate_to_i18n(entry)
50
+ if entry.is_a?(Hash) && (entry[:translation] || entry[:t] || entry[:default])
51
+ entry = entry[:translation] || entry[:t] || entry[:default]
52
+ end
53
+ entry
37
54
  end
38
55
 
39
56
  end # module Backend::Translator
@@ -87,6 +87,7 @@ I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
87
87
  I18n::Backend::Simple.send(:include, I18n::Backend::PO)
88
88
  I18n::Backend::Simple.send(:include, I18n::Backend::TS)
89
89
  I18n::Backend::Simple.send(:include, I18n::Backend::Properties)
90
+ I18n.config.enforce_available_locales = false
90
91
  I18n.default_locale = 'default'
91
92
  I18n.locale = 'cze'
92
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-translators-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Kovar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.0
19
+ version: 0.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.0
26
+ version: 0.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ya2yaml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +130,9 @@ post_install_message: |
130
130
  * statistics
131
131
 
132
132
  Changelog:
133
+ v0.2.6
134
+ * compatible with i18n 0.7.0
135
+ * make it works with rails 4.2
133
136
  v0.2.5
134
137
  * fix recursive directory scan (-r and --deep options should work now)
135
138
  * enables usage require 'i18n-translators-tools'