active_translation 0.7.6 → 0.7.7
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 +4 -4
- data/lib/active_translation/translatable.rb +7 -15
- data/lib/active_translation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c5060f0fe015b2284bcb3099e6a9287a5dac0bbc8f0cb8f8172c0d068dcfb714
|
|
4
|
+
data.tar.gz: 25abebd6fff9da4101bf2aca097085b9314c0b217b3de1547b597f2f641e95c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be37b5420e08aa497dc213784b4101eb09de9fd645fe14c974dbd0659453251242a55e90ffba89afd6194067edfdf3c3a344294b20a63be7fda7a0deb1ad18b4
|
|
7
|
+
data.tar.gz: e9afd718cec5a0a67035c8e6656579e57993caf67ff6e8b39254e6f9b3301c31c894ffeb41e16375b8dd30554cd30063f8d74f37ad200747feecdb3308ba8618
|
|
@@ -168,22 +168,14 @@ module ActiveTranslation
|
|
|
168
168
|
|
|
169
169
|
translated_text = cached_translation&.translated_text || ActiveTranslation::GoogleTranslate.translate(target_language_code: locale, text: send(attribute))
|
|
170
170
|
|
|
171
|
-
case translation_config[:cache]
|
|
172
|
-
when TrueClass
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
when String, Symbol
|
|
178
|
-
return unless attribute.to_s == translation_config[:cache].to_s
|
|
179
|
-
|
|
180
|
-
ActiveTranslation::Cache.find_or_create_by(
|
|
181
|
-
checksum: text_checksum(send(attribute)),
|
|
182
|
-
locale:,
|
|
183
|
-
).update(translated_text:,)
|
|
184
|
-
when Array
|
|
185
|
-
return unless translation_config[:cache].map(&:to_s).include? attribute.to_s
|
|
171
|
+
should_cache = case translation_config[:cache]
|
|
172
|
+
when TrueClass then true
|
|
173
|
+
when String, Symbol then attribute.to_s == translation_config[:cache].to_s
|
|
174
|
+
when Array then translation_config[:cache].map(&:to_s).include?(attribute.to_s)
|
|
175
|
+
else false
|
|
176
|
+
end
|
|
186
177
|
|
|
178
|
+
if should_cache
|
|
187
179
|
ActiveTranslation::Cache.find_or_create_by(
|
|
188
180
|
checksum: text_checksum(send(attribute)),
|
|
189
181
|
locale:,
|