i18n-active_record 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 9a66ea934bb11309eb79e45fe45b206f596aecdef52de87d193b8d9ec9a8ac54
4
- data.tar.gz: 92f91630acf638a76c02a527142c51565c8422bf1a9443254ba8eeca1a6ad0f8
3
+ metadata.gz: 402118f9fb5b5b88dec6745249ded8e131b509c3bb4b8b35e5857182c85e6ca8
4
+ data.tar.gz: f120411a8ffc00c065ef50eda91d32515e23f51d6e4125184513c5a34496edb5
5
5
  SHA512:
6
- metadata.gz: 6683c1ff6494df8ef79f0d96398842e0315a1a66d6850d0abc13157de0b45faa9728121c55459ccfa78ad70497faab5a084e2e64ad53d148647ad5fbe4fda433
7
- data.tar.gz: 2699f7f14fd099990a227ee9cf5e8bd5a1d65957f2e752fcda2624220dfabc470c13b4c4f5f561578d2a79becf67dbc015517656a0f62d52d3e17f4c7f52d2bd
6
+ metadata.gz: f36d522e0792d4c5460fe9d7b3af69d2fa27817f2f2ecd58eb18ecdcea13012e542bfe4022d2e27c18f454107e63c1406450c3d709830caeb1c33f1a0b2997b3
7
+ data.tar.gz: 7ee1bec18a25efbad1fbec55e89b061b050cfdf2fc51c2453f6dee559ad71bf60ab8c5d8397900c4d87be82dff59f830e494c427c42214d60469c047d06c08fc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module ActiveRecord
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
@@ -42,7 +42,7 @@ module I18n
42
42
  flatten_translations(locale, data, escape, false).each do |key, value|
43
43
  translation = Translation.locale(locale).lookup(expand_keys(key))
44
44
 
45
- if ActiveRecord.config.cleanup_with_destroy
45
+ if self.class.config.cleanup_with_destroy
46
46
  translation.destroy_all
47
47
  else
48
48
  translation.delete_all
@@ -51,7 +51,7 @@ module I18n
51
51
  Translation.create(locale: locale.to_s, key: key.to_s, value: value)
52
52
  end
53
53
 
54
- reload! if ActiveRecord.config.cache_translations
54
+ reload! if self.class.config.cache_translations
55
55
  end
56
56
 
57
57
  def reload!
@@ -80,9 +80,7 @@ module I18n
80
80
  key = key[1..-1] if key.first == '.'
81
81
  key = key[0..-2] if key.last == '.'
82
82
 
83
- if ActiveRecord.config.cache_translations
84
- init_translations if @translations.nil? || @translations.empty?
85
-
83
+ if self.class.config.cache_translations
86
84
  keys = ([locale] + key.split(I18n::Backend::Flatten::FLATTEN_SEPARATOR)).map(&:to_sym)
87
85
 
88
86
  return translations.dig(*keys)
@@ -162,5 +162,14 @@ class I18nBackendActiveRecordTest < I18n::TestCase
162
162
 
163
163
  I18n::Backend::ActiveRecord.config.cache_translations = true
164
164
  end
165
+
166
+ test 'reinitialization when the DB is empty' do
167
+ I18n::Backend::ActiveRecord::Translation.destroy_all
168
+
169
+ I18n.backend.init_translations
170
+ I18n.backend.expects(:init_translations).never
171
+
172
+ I18n.t('foo')
173
+ end
165
174
  end
166
175
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n