mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-01 12:02:16 +00:00
17 lines
386 B
Ruby
17 lines
386 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module DiscourseAi
|
||
|
module Translation
|
||
|
class PostLocaleDetector
|
||
|
def self.detect_locale(post)
|
||
|
return if post.blank?
|
||
|
|
||
|
detected_locale = LanguageDetector.new(post.raw).detect
|
||
|
locale = LocaleNormalizer.normalize_to_i18n(detected_locale)
|
||
|
post.update_column(:locale, locale)
|
||
|
locale
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|