translation_engine 0.0.3 → 0.0.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: d9403edc4263e3baab5d75038e0ce23c2d3e3b46
4
- data.tar.gz: 63b5ce8b73ebe6a3866913167d347feae3048830
3
+ metadata.gz: 498b874a47bd3849b2b910180113ddbce2bdecaf
4
+ data.tar.gz: fc2622bab03ff94006fa2c3a970a05a58834ff68
5
5
  SHA512:
6
- metadata.gz: a527f2cc3b1387ce2e44d0fcfa04c169c87e1575acbe5d1e4319366ba39604ee37399d96959fc1e9e8cb6b525253690748314c41cc3bec96f61973faf9e62249
7
- data.tar.gz: ac3c31d8ee464e4d11cd25be693122b0d9765c7e210b56c016c185559b6d2aea0fc877162a4709b50bb20bdc14409f97d3de5edd1e598e1fe522d8f54838ebd9
6
+ metadata.gz: b52e523013ea5d167280451c3b0d4b86a27b4a7ddff708ce00f8f9631448b6a3b9614e66ad4849ba70e3aa6eacec69bae7767dddb66677326c724c879f6c623d
7
+ data.tar.gz: 5d178901b241444101fd1d705e74a431a9a99db90e2113e2b9e21fe98a6b4a078fbb202e9f629c795140d88d6e00be1c17c99fb2fdc24ce6181e28b3037e7291
@@ -50,14 +50,24 @@ class TranslationEngine::Backend < I18n::Backend::Simple
50
50
  end
51
51
  end
52
52
 
53
- def lookup(locale, key, scope = [], options = {})
54
- keys = I18n.normalize_keys(locale, key, scope, options[:separator])
55
- resolved = super
56
- if resolved
57
- enhance_translation(resolved, keys)
58
- else
59
- resolved
53
+ def resolve(locale, object, subject, options = {})
54
+ return subject if options[:resolve] == false
55
+
56
+ result = catch(:exception) do
57
+ case subject
58
+ when Symbol
59
+ I18n.translate(subject, options.merge(:locale => locale, :throw => true))
60
+ when Proc
61
+ date_or_time = options.delete(:object) || object
62
+ resolve(locale, object, subject.call(date_or_time, options))
63
+ when nil
64
+ nil
65
+ else
66
+ keys = I18n.normalize_keys(locale, object, options[:scope], options[:separator])
67
+ enhance_translation(subject, keys)
68
+ end
60
69
  end
70
+ result unless result.is_a?(I18n::MissingTranslation)
61
71
  end
62
72
 
63
73
  def enhance_translation(value, main_keys, catch_translation = true)
@@ -1,3 +1,3 @@
1
1
  module TranslationEngine
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.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
26
  version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency