translation_engine 0.0.5 → 0.0.7

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: eb36f44885cef5545e9df7361ab089e45bee2b80
4
- data.tar.gz: b4df90289442d36754e104d8179b11d8a2711e29
3
+ metadata.gz: 9fe1fe423c1d6f03f4ae78c9844c6a3d323145aa
4
+ data.tar.gz: 587f1400dc639320918de9d263eba5f64882e9a0
5
5
  SHA512:
6
- metadata.gz: 5ac92beba66ec7ac5e2ce84286d850e37d3264134d0c0ab97779b839c0d434f81d19f0a3970821d5f50edbab75b6f7f11b0d8ed7d8070d4a7a64931dbfc73f98
7
- data.tar.gz: 41e21bdad0790d639ffec1878c01ead3467e86cda7c59de4a4bb0d0b7238a3006ccad36cfb49a1c43f8f8f827a03d4063eda2fbaf3cc4d34995e7c15a97a36d9
6
+ metadata.gz: b9700d616cbd5d57b8c87a6a56111f15e2641c03ed8e7783ad324df5592ff597304356c98209a4f7e4e7590b01ad1e1f2331b56d05fe6a8dbbc9d7018aa39c56
7
+ data.tar.gz: 72b45e1e4728d1d6af962047bb8ca9794b849dad7bacd59e45a8332b5a600eaa956fd0cd2028497ec1f83553d26b07a73f44228f8795880b6bd5a20877af32b4
@@ -10,8 +10,12 @@ class TranslationEngine::Downloader
10
10
  response
11
11
  end
12
12
 
13
+ def self.cache_timeout
14
+ @cache_timeout
15
+ end
16
+
13
17
  def update
14
- return nil if @cache_timeout && Time.now < @cache_timeout
18
+ return nil if self.class.cache_timeout && Time.now < self.class.cache_timeout
15
19
  return nil if self.class.etag?(connection.get_translations_head[:etag])
16
20
  I18n.backend.reload!
17
21
  end
@@ -58,7 +58,7 @@ class TranslationEngine::Translation
58
58
  end
59
59
 
60
60
  def to_s
61
- if TranslationEngine.use_screenshots && @text.is_a?(String)
61
+ if TranslationEngine.use_screenshots && @text.is_a?(String) && !full_key.include?('.routes')
62
62
  "--TRANSLATION--#{full_key}--#{@text}"
63
63
  else
64
64
  @text
@@ -24,6 +24,40 @@ module TranslationEngine
24
24
  config.after_initialize do |app|
25
25
  if TranslationEngine.use_catcher || TranslationEngine.use_screenshots
26
26
  I18n.backend = TranslationEngine::Backend.new
27
+
28
+ I18n::Backend::Fallbacks.module_eval do
29
+ # Fixing problem in Fallback Backend!
30
+ # https://github.com/svenfuchs/i18n/blob/master/lib/i18n/backend/fallbacks.rb#L37
31
+ def translate(locale, key, options = {})
32
+ return super unless options.fetch(:fallback, true)
33
+ return super if (@fallback_locked ||= false)
34
+ default = extract_non_symbol_default!(options) if options[:default]
35
+
36
+ begin
37
+ @fallback_locked = true
38
+ I18n.fallbacks[locale].each do |fallback|
39
+ begin
40
+ catch(:exception) do
41
+ result = super(fallback, key, options)
42
+ return result if (result.nil? && options.key?(:default) && options[:default].nil?) || !result.nil?
43
+ end
44
+ rescue I18n::InvalidLocale
45
+ # we do nothing when the locale is invalid, as this is a fallback anyways.
46
+ end
47
+ end
48
+ ensure
49
+ @fallback_locked = false
50
+ end
51
+
52
+ # Original code is:
53
+ # return super(locale, nil, options.merge(:default => default)) if default
54
+ # And fix is adding key:
55
+ return super(locale, key, options.merge(:default => default)) if default
56
+
57
+ throw(:exception, I18n::MissingTranslation.new(locale, key, options))
58
+ end
59
+ end
60
+
27
61
  end
28
62
  end
29
63
  end
@@ -1,3 +1,3 @@
1
1
  module TranslationEngine
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-15 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails