0
0
Fork 0

Leave unknown language as nil if account is remote (#8861)

* Force use language detector if account is remote

* Set unknown remote toot's language as nil
This commit is contained in:
Jeong Arm 2018-10-06 02:17:46 +09:00 committed by Eugen Rochko
parent 9a42b75f00
commit 144d73730d
2 changed files with 13 additions and 1 deletions

View file

@ -12,6 +12,7 @@ class LanguageDetector
def detect(text, account)
input_text = prepare_text(text)
return if input_text.blank?
detect_language_code(input_text) || default_locale(account)
end
@ -33,6 +34,7 @@ class LanguageDetector
def detect_language_code(text)
return if unreliable_input?(text)
result = @identifier.find_language(text)
iso6391(result.language.to_s).to_sym if result.reliable?
end
@ -75,6 +77,6 @@ class LanguageDetector
end
def default_locale(account)
account.user_locale&.to_sym || I18n.default_locale
return account.user_locale&.to_sym || I18n.default_locale if account.local?
end
end