active_translation 0.7.5 → 0.7.6
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80d790063e336ec762cf5374a7eb30e2858d04e04ff5c03e952358481262039a
|
|
4
|
+
data.tar.gz: 251987c1c7b1147547741567fc819f8680595e486e8d0e67997439305436941b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd8bc53b2c7101fa908b90d8dc6076f63967452b6095f686c6a6590d2e9a40daae08897bb57ff4c1463b37f469344cfe18514b22fcdc42da335c00388e2ab5ab
|
|
7
|
+
data.tar.gz: 5fd085e8de592630f851874f68a8079f6de8213c1fc131005894abde22e3f9eb1972b375051f5665c0dbb9accea9bd3d5d6dd77c93471a0add7f4e746dcc587e
|
|
@@ -6,6 +6,8 @@ module ActiveTranslation
|
|
|
6
6
|
class GoogleTranslate
|
|
7
7
|
class << self
|
|
8
8
|
def translate(target_language_code:, text:, source: "en-US", obj: nil)
|
|
9
|
+
return "[#{target_language_code}] #{text}" if Rails.env.test?
|
|
10
|
+
|
|
9
11
|
conn = Faraday.new(url: "https://translation.googleapis.com/") do |faraday|
|
|
10
12
|
faraday.request :json
|
|
11
13
|
faraday.response :json
|
|
@@ -166,11 +166,7 @@ module ActiveTranslation
|
|
|
166
166
|
locale: locale,
|
|
167
167
|
)
|
|
168
168
|
|
|
169
|
-
translated_text =
|
|
170
|
-
cached_translation&.translated_text || "[#{locale}] #{send(attribute)}"
|
|
171
|
-
else
|
|
172
|
-
cached_translation&.translated_text || ActiveTranslation::GoogleTranslate.translate(target_language_code: locale, text: text)
|
|
173
|
-
end
|
|
169
|
+
translated_text = cached_translation&.translated_text || ActiveTranslation::GoogleTranslate.translate(target_language_code: locale, text: send(attribute))
|
|
174
170
|
|
|
175
171
|
case translation_config[:cache]
|
|
176
172
|
when TrueClass
|