translated 0.7.0 → 0.9.0
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/app/jobs/translated/update_translations_job.rb +1 -0
- data/app/models/translated/translated_text_field.rb +13 -4
- data/app/models/translated/translator.rb +1 -1
- data/db/migrate/202405031152_create_translated_translated_text_fields.rb +3 -1
- data/db/migrate/20260320000000_change_translated_text_fields_content_to_json.rb +11 -0
- data/lib/translated/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b95aed2d25b4b0a95a1cbf681ef2555df0e26ffa5cb12d6d6db1e3a143506b1
|
|
4
|
+
data.tar.gz: b511622e5d621c04b26a6fdeda30df5dc1f1430c01c7ee1312e72781cd42e3fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cc9520ab86ec4e53df75467c327165f0cf91253d99219e99fc497922ed064d6111f266ddf14587ccee5c763ec19efb05e43fd633c542250627c8a76e9fd5068
|
|
7
|
+
data.tar.gz: 9b06c6abe08b37f28a117c0d1eeff27da4086cd99a43bf232a90e3cf7606824e32de69ee99c78e6c3c33402c62636137a4b86b14cdafb6dd2ea1ee1580f336a7
|
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
module Translated
|
|
4
4
|
class TranslatedTextField < ApplicationRecord
|
|
5
|
-
serialize :content, coder: JSON
|
|
6
|
-
|
|
7
5
|
belongs_to :translatable, polymorphic: true
|
|
8
6
|
|
|
9
7
|
validates :language, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
|
|
10
8
|
|
|
11
|
-
scope :with_missing_translations,
|
|
12
|
-
|
|
9
|
+
scope :with_missing_translations, lambda {
|
|
10
|
+
json_length_expression = case connection.adapter_name
|
|
11
|
+
when /mysql/i
|
|
12
|
+
'JSON_LENGTH(content)'
|
|
13
|
+
when /sqlite/i
|
|
14
|
+
"(SELECT count(*) FROM json_each(#{table_name}.content))"
|
|
15
|
+
when /postgres/i
|
|
16
|
+
'(SELECT count(*) FROM jsonb_each_text(content::jsonb))'
|
|
17
|
+
else
|
|
18
|
+
'JSON_LENGTH(content)'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
where.not(id: where("#{json_length_expression} >= ?", I18n.available_locales.size))
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
after_commit :update_translations_later, if: :needs_translations?
|
|
@@ -19,7 +19,7 @@ module Translated
|
|
|
19
19
|
content_type: :json
|
|
20
20
|
)
|
|
21
21
|
JSON.parse(response.body)['translated_text']
|
|
22
|
-
rescue RestClient::GatewayTimeout => e
|
|
22
|
+
rescue RestClient::GatewayTimeout, RestClient::BadGateway => e
|
|
23
23
|
retries += 1
|
|
24
24
|
if retries <= MAX_RETRIES
|
|
25
25
|
sleep(RETRY_DELAY * retries) # exponential backoff
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateTranslatedTranslatedTextFields < ActiveRecord::Migration[7.1]
|
|
2
4
|
def change
|
|
3
5
|
create_table :translated_translated_text_fields do |t|
|
|
4
6
|
t.references :translatable, polymorphic: true, null: false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ChangeTranslatedTextFieldsContentToJson < ActiveRecord::Migration[7.1]
|
|
4
|
+
def up
|
|
5
|
+
change_column :translated_translated_text_fields, :content, :json
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def down
|
|
9
|
+
change_column :translated_translated_text_fields, :content, :text
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/translated/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: translated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trae Robrock
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-03-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activejob
|
|
@@ -100,6 +100,7 @@ files:
|
|
|
100
100
|
- app/models/translated/translated_text_field.rb
|
|
101
101
|
- app/models/translated/translator.rb
|
|
102
102
|
- db/migrate/202405031152_create_translated_translated_text_fields.rb
|
|
103
|
+
- db/migrate/20260320000000_change_translated_text_fields_content_to_json.rb
|
|
103
104
|
- lib/tasks/translated_tasks.rake
|
|
104
105
|
- lib/translated.rb
|
|
105
106
|
- lib/translated/configuration.rb
|