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 +4 -4
- data/lib/i18n/active_record/version.rb +1 -1
- data/lib/i18n/backend/active_record.rb +3 -5
- data/test/active_record_test.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 402118f9fb5b5b88dec6745249ded8e131b509c3bb4b8b35e5857182c85e6ca8
|
4
|
+
data.tar.gz: f120411a8ffc00c065ef50eda91d32515e23f51d6e4125184513c5a34496edb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f36d522e0792d4c5460fe9d7b3af69d2fa27817f2f2ecd58eb18ecdcea13012e542bfe4022d2e27c18f454107e63c1406450c3d709830caeb1c33f1a0b2997b3
|
7
|
+
data.tar.gz: 7ee1bec18a25efbad1fbec55e89b061b050cfdf2fc51c2453f6dee559ad71bf60ab8c5d8397900c4d87be82dff59f830e494c427c42214d60469c047d06c08fc
|
@@ -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
|
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
|
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
|
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)
|
data/test/active_record_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|