From 629d35e6f5d353d30661c1af7bbcc8aa6411e698 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 21 Apr 2017 22:26:25 -0400 Subject: [WIP] Html lang on statuses (#2297) * Add html lang attributes around statuses * Remove urls from language detection --- app/lib/language_detector.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/lib') diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb index b6f81923b..9a32d6a64 100644 --- a/app/lib/language_detector.rb +++ b/app/lib/language_detector.rb @@ -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 -- cgit