discourse-translator/app/jobs/regular/detect_translatable_language.rb
Natalie Tay 95a5cfe304
DEV: Cleanup terms (#232)
Doing some cleanup
- `experimental_topic_translation` becomes `experimental_inline_translation`
- `translator` becomes `translator_provider`
- DualText translation is now Parallel Translation (the feature where translation is appended to the post, rather than shown inline)
- Unused `translate_posts_to_languages` removed
2025-02-27 17:40:56 +08:00

21 lines
690 B
Ruby

# frozen_string_literal: true
module ::Jobs
class DetectTranslatableLanguage < ::Jobs::Base
def execute(args)
return unless SiteSetting.translator_enabled
return if !%w[Post Topic].include?(args[:type])
return if !args[:translatable_id].is_a?(Integer)
translatable = args[:type].constantize.find_by(id: args[:translatable_id])
return if translatable.blank?
begin
translator = "DiscourseTranslator::#{SiteSetting.translator_provider}".constantize
translator.detect(translatable)
rescue ::DiscourseTranslator::ProblemCheckedTranslationError
# problem-checked translation errors gracefully
end
end
end
end