DEV: Remove 'experimental' from translation features (#1439)

* DEV: Remove 'experimental' from translation features

* include compat

* include compat
This commit is contained in:
Natalie Tay 2025-06-19 12:23:56 +08:00 committed by GitHub
parent cd14b0c0be
commit 3e87e92631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 24 additions and 23 deletions

View File

@ -1,3 +1,4 @@
< 3.5.0.beta7-dev: cd14b0c0bee0cf63c59b64b6f7213e31a37f11a7
< 3.5.0.beta6-dev: 3e74eea1e5e3143888d67a8d8a11206df214dc24 < 3.5.0.beta6-dev: 3e74eea1e5e3143888d67a8d8a11206df214dc24
< 3.5.0.beta3-dev: 09a68414804a1447f52e5d60691ba59742cda9ec < 3.5.0.beta3-dev: 09a68414804a1447f52e5d60691ba59742cda9ec
< 3.5.0.beta2-dev: de8624416a15b3d8e7ad350b083cc1420451ccec < 3.5.0.beta2-dev: de8624416a15b3d8e7ad350b083cc1420451ccec

View File

@ -36,7 +36,7 @@ module Jobs
end end
end end
locales = SiteSetting.experimental_content_localization_supported_locales.split("|") locales = SiteSetting.content_localization_supported_locales.split("|")
return if locales.blank? return if locales.blank?
locales.each do |locale| locales.each do |locale|

View File

@ -34,7 +34,7 @@ module Jobs
end end
end end
locales = SiteSetting.experimental_content_localization_supported_locales.split("|") locales = SiteSetting.content_localization_supported_locales.split("|")
return if locales.blank? return if locales.blank?
locales.each do |locale| locales.each do |locale|

View File

@ -11,7 +11,7 @@ module Jobs
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
locales = SiteSetting.experimental_content_localization_supported_locales.split("|") locales = SiteSetting.content_localization_supported_locales.split("|")
return if locales.blank? return if locales.blank?
cat_id = args[:from_category_id] || Category.order(:id).first&.id cat_id = args[:from_category_id] || Category.order(:id).first&.id

View File

@ -11,7 +11,7 @@ module Jobs
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
locales = SiteSetting.experimental_content_localization_supported_locales.split("|") locales = SiteSetting.content_localization_supported_locales.split("|")
return if locales.blank? return if locales.blank?
limit = args[:limit] || BATCH_SIZE limit = args[:limit] || BATCH_SIZE

View File

@ -11,7 +11,7 @@ module Jobs
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
locales = SiteSetting.experimental_content_localization_supported_locales.split("|") locales = SiteSetting.content_localization_supported_locales.split("|")
return if locales.blank? return if locales.blank?
limit = args[:limit] || BATCH_SIZE limit = args[:limit] || BATCH_SIZE

View File

@ -8,7 +8,7 @@ module Jobs
def execute(args) def execute(args)
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
return if SiteSetting.experimental_content_localization_supported_locales.blank? return if SiteSetting.content_localization_supported_locales.blank?
Jobs.enqueue(:localize_categories) Jobs.enqueue(:localize_categories)
end end

View File

@ -9,7 +9,7 @@ module Jobs
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
return if SiteSetting.experimental_content_localization_supported_locales.blank? return if SiteSetting.content_localization_supported_locales.blank?
return if SiteSetting.ai_translation_backfill_rate == 0 return if SiteSetting.ai_translation_backfill_rate == 0
Jobs.enqueue(:localize_posts, limit: SiteSetting.ai_translation_backfill_rate) Jobs.enqueue(:localize_posts, limit: SiteSetting.ai_translation_backfill_rate)

View File

@ -9,7 +9,7 @@ module Jobs
return if !SiteSetting.discourse_ai_enabled return if !SiteSetting.discourse_ai_enabled
return if !SiteSetting.ai_translation_enabled return if !SiteSetting.ai_translation_enabled
return if SiteSetting.experimental_content_localization_supported_locales.blank? return if SiteSetting.content_localization_supported_locales.blank?
return if SiteSetting.ai_translation_backfill_rate == 0 return if SiteSetting.ai_translation_backfill_rate == 0
Jobs.enqueue(:localize_topics, limit: SiteSetting.ai_translation_backfill_rate) Jobs.enqueue(:localize_topics, limit: SiteSetting.ai_translation_backfill_rate)

View File

@ -12,7 +12,7 @@ describe Jobs::DetectTranslatePost do
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = locales.join("|") SiteSetting.content_localization_supported_locales = locales.join("|")
end end
it "does nothing when translator is disabled" do it "does nothing when translator is disabled" do
@ -55,7 +55,7 @@ describe Jobs::DetectTranslatePost do
end end
it "does not translate when no target languages are configured" do it "does not translate when no target languages are configured" do
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
DiscourseAi::Translation::PostLocaleDetector.expects(:detect_locale).with(post).returns("en") DiscourseAi::Translation::PostLocaleDetector.expects(:detect_locale).with(post).returns("en")
DiscourseAi::Translation::PostLocalizer.expects(:localize).never DiscourseAi::Translation::PostLocalizer.expects(:localize).never

View File

@ -12,7 +12,7 @@ describe Jobs::DetectTranslateTopic do
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = locales.join("|") SiteSetting.content_localization_supported_locales = locales.join("|")
end end
it "does nothing when translator is disabled" do it "does nothing when translator is disabled" do
@ -55,7 +55,7 @@ describe Jobs::DetectTranslateTopic do
end end
it "does not translate when no target languages are configured" do it "does not translate when no target languages are configured" do
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
DiscourseAi::Translation::TopicLocaleDetector.expects(:detect_locale).with(topic).returns("en") DiscourseAi::Translation::TopicLocaleDetector.expects(:detect_locale).with(topic).returns("en")
DiscourseAi::Translation::TopicLocalizer.expects(:localize).never DiscourseAi::Translation::TopicLocalizer.expects(:localize).never

View File

@ -15,7 +15,7 @@ describe Jobs::LocalizeCategories do
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = "pt|zh_CN" SiteSetting.content_localization_supported_locales = "pt|zh_CN"
Jobs.run_immediately! Jobs.run_immediately!
end end
@ -37,7 +37,7 @@ describe Jobs::LocalizeCategories do
end end
it "does nothing when no target languages are configured" do it "does nothing when no target languages are configured" do
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
DiscourseAi::Translation::CategoryLocalizer.expects(:localize).never DiscourseAi::Translation::CategoryLocalizer.expects(:localize).never

View File

@ -12,7 +12,7 @@ describe Jobs::LocalizePosts do
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = locales.join("|") SiteSetting.content_localization_supported_locales = locales.join("|")
end end
it "does nothing when translator is disabled" do it "does nothing when translator is disabled" do
@ -30,7 +30,7 @@ describe Jobs::LocalizePosts do
end end
it "does nothing when no target languages are configured" do it "does nothing when no target languages are configured" do
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
DiscourseAi::Translation::PostLocalizer.expects(:localize).never DiscourseAi::Translation::PostLocalizer.expects(:localize).never
job.execute({}) job.execute({})
@ -136,7 +136,7 @@ describe Jobs::LocalizePosts do
fab!(:group_pm_topic) { Fabricate(:group_private_message_topic, recipient_group: group) } fab!(:group_pm_topic) { Fabricate(:group_private_message_topic, recipient_group: group) }
fab!(:group_pm_post) { Fabricate(:post, topic: group_pm_topic, locale: "es") } fab!(:group_pm_post) { Fabricate(:post, topic: group_pm_topic, locale: "es") }
before { SiteSetting.experimental_content_localization_supported_locales = "ja" } before { SiteSetting.content_localization_supported_locales = "ja" }
context "when ai_translation_backfill_limit_to_public_content is true" do context "when ai_translation_backfill_limit_to_public_content is true" do
before { SiteSetting.ai_translation_backfill_limit_to_public_content = true } before { SiteSetting.ai_translation_backfill_limit_to_public_content = true }
@ -187,7 +187,7 @@ describe Jobs::LocalizePosts do
before do before do
SiteSetting.ai_translation_backfill_max_age_days = 5 SiteSetting.ai_translation_backfill_max_age_days = 5
SiteSetting.experimental_content_localization_supported_locales = "ja" SiteSetting.content_localization_supported_locales = "ja"
end end
it "only processes posts within the age limit" do it "only processes posts within the age limit" do

View File

@ -12,7 +12,7 @@ describe Jobs::LocalizeTopics do
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = locales.join("|") SiteSetting.content_localization_supported_locales = locales.join("|")
end end
it "does nothing when translator is disabled" do it "does nothing when translator is disabled" do
@ -30,7 +30,7 @@ describe Jobs::LocalizeTopics do
end end
it "does nothing when no target languages are configured" do it "does nothing when no target languages are configured" do
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
DiscourseAi::Translation::TopicLocalizer.expects(:localize).never DiscourseAi::Translation::TopicLocalizer.expects(:localize).never
job.execute({}) job.execute({})
@ -139,7 +139,7 @@ describe Jobs::LocalizeTopics do
Fabricate(:group_private_message_topic, recipient_group: Fabricate(:group), locale: "es") Fabricate(:group_private_message_topic, recipient_group: Fabricate(:group), locale: "es")
end end
before { SiteSetting.experimental_content_localization_supported_locales = "ja" } before { SiteSetting.content_localization_supported_locales = "ja" }
context "when ai_translation_backfill_limit_to_public_content is true" do context "when ai_translation_backfill_limit_to_public_content is true" do
before { SiteSetting.ai_translation_backfill_limit_to_public_content = true } before { SiteSetting.ai_translation_backfill_limit_to_public_content = true }

View File

@ -3,7 +3,7 @@
describe Jobs::PostLocalizationBackfill do describe Jobs::PostLocalizationBackfill do
before do before do
SiteSetting.ai_translation_backfill_rate = 100 SiteSetting.ai_translation_backfill_rate = 100
SiteSetting.experimental_content_localization_supported_locales = "en" SiteSetting.content_localization_supported_locales = "en"
Fabricate(:fake_model).tap do |fake_llm| Fabricate(:fake_model).tap do |fake_llm|
SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}") SiteSetting.public_send("ai_translation_model=", "custom:#{fake_llm.id}")
end end
@ -29,7 +29,7 @@ describe Jobs::PostLocalizationBackfill do
it "does not enqueue psot translation if backfill languages are not set" do it "does not enqueue psot translation if backfill languages are not set" do
SiteSetting.discourse_ai_enabled = true SiteSetting.discourse_ai_enabled = true
SiteSetting.ai_translation_enabled = true SiteSetting.ai_translation_enabled = true
SiteSetting.experimental_content_localization_supported_locales = "" SiteSetting.content_localization_supported_locales = ""
described_class.new.execute({}) described_class.new.execute({})