Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/jobs/scheduled/automatic_translation_backfill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def translate_records(type, record_ids)
def process_batch
models_translated = [Post, Topic].size
translations_per_model = [translations_per_run / models_translated, 1].max
topic_ids = fetch_untranslated_model_ids(Topic, "title", translations_per_model)
topic_ids = fetch_untranslated_model_ids(Topic, "fancy_title", translations_per_model)
translations_per_model = translations_per_run - topic_ids.size
post_ids = fetch_untranslated_model_ids(Post, "cooked", translations_per_model)
return if topic_ids.empty? && post_ids.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/services/discourse_translator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def self.get_text(translatable)
when "Post"
translatable.cooked
when "Topic"
translatable.title
translatable.fancy_title
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/discourse_translator/topic_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module DiscourseTranslator
module TopicExtension
extend ActiveSupport::Concern
prepended { before_update :clear_translations, if: :title_changed? }
prepended { before_update :clear_translations, if: :fancy_title_changed? }
include Translatable
end
end
2 changes: 1 addition & 1 deletion spec/models/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
describe "translatable" do
fab!(:post)

it "should reset translation data when post title has been updated" do
it "should reset translation data when post raw has been updated" do
Fabricate(:post_translation, post:)
Fabricate(:post_locale, post:)
post.update!(raw: "this is an updated title")
Expand Down
4 changes: 2 additions & 2 deletions spec/models/topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

before { SiteSetting.translator_enabled = true }

it "should reset translation data when topic title has been updated" do
it "should reset translation data when topic fancy_title has been updated" do
Fabricate(:topic_translation, topic:)
Fabricate(:topic_locale, topic:)
topic.update!(title: "this is an updated title")
topic.update!(fancy_title: "this is an updated title")

expect(DiscourseTranslator::TopicLocale.where(topic:)).to be_empty
expect(DiscourseTranslator::TopicLocale.find_by(topic:)).to be_nil
Expand Down
3 changes: 2 additions & 1 deletion spec/serializers/basic_topic_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
let!(:jap_title) { "フス・ロ・ダ・ア" }

before do
topic.title = original_title
topic.title = "x"
topic.fancy_title = original_title
SiteSetting.experimental_topic_translation = true
I18n.locale = "ja"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/topic_view_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
let!(:jap_title) { "フス・ロ・ダ・ア" }

before do
topic.title = original_title
topic.fancy_title = original_title
SiteSetting.experimental_topic_translation = true
I18n.locale = "ja"
end
Expand Down Expand Up @@ -76,7 +76,7 @@ def serialize_topic(guardian_user: user, params: {})
expect(serialize_topic.fancy_title).to eq(topic.fancy_title)
end

it "returns translated title in fancy_title when translation exists for current locale" do
it "returns translated fancy title in fancy_title when translation exists for current locale" do
topic.set_translation("ja", jap_title)
expect(serialize_topic.fancy_title).to eq(jap_title)
end
Expand Down
Loading