[WIP] Html lang on statuses (#2297)
* Add html lang attributes around statuses * Remove urls from language detection
This commit is contained in:
parent
67dea31b0f
commit
629d35e6f5
4 changed files with 23 additions and 3 deletions
|
@ -9,11 +9,19 @@ class LanguageDetector
|
|||
end
|
||||
|
||||
def to_iso_s
|
||||
WhatLanguage.new(:all).language_iso(text) || default_locale.to_sym
|
||||
WhatLanguage.new(:all).language_iso(text_without_urls) || default_locale.to_sym
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def text_without_urls
|
||||
text.dup.tap do |new_text|
|
||||
URI.extract(new_text).each do |url|
|
||||
new_text.gsub!(url, '')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def default_locale
|
||||
account&.user&.locale || I18n.default_locale
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue