mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-23 22:43:27 +00:00
This commit - normalizes locales like en_GB and variants to en. With this, the feature will not translate en_GB posts to en (or similarly pt_BR to pt_PT) - consolidates whether the feature is enabled in `DiscourseAi::Translation.enabled?` - similarly for backfill in `DiscourseAi::Translation.backfill_enabled?` - turns off backfill if `ai_translation_backfill_max_age_days` is 0 to keep true to what it says. Set it to a high number to backfill everything
28 lines
745 B
Ruby
28 lines
745 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Translation
|
|
class EntryPoint
|
|
def inject_into(plugin)
|
|
plugin.on(:post_created) do |post|
|
|
if DiscourseAi::Translation.enabled?
|
|
Jobs.enqueue(:detect_translate_post, post_id: post.id)
|
|
end
|
|
end
|
|
|
|
plugin.on(:topic_created) do |topic|
|
|
if DiscourseAi::Translation.enabled?
|
|
Jobs.enqueue(:detect_translate_topic, topic_id: topic.id)
|
|
end
|
|
end
|
|
|
|
plugin.on(:post_edited) do |post, topic_changed|
|
|
if DiscourseAi::Translation.enabled? && topic_changed
|
|
Jobs.enqueue(:detect_translate_topic, topic_id: post.topic_id)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|