0
0
Fork 0

Change RTL detection to rely on unicode-bidi paragraph by paragraph (#14573)

This commit is contained in:
Eugen Rochko 2020-12-15 12:56:43 +01:00 committed by GitHub
parent 1045549f85
commit 1f564051b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 106 deletions

View file

@ -92,22 +92,6 @@ module StatusesHelper
end
end
def rtl_status?(status)
status.local? ? rtl?(status.text) : rtl?(strip_tags(status.text))
end
def rtl?(text)
text = simplified_text(text)
rtl_words = text.scan(/[\p{Hebrew}\p{Arabic}\p{Syriac}\p{Thaana}\p{Nko}]+/m)
if rtl_words.present?
total_size = text.size.to_f
rtl_size(rtl_words) / total_size > 0.3
else
false
end
end
def fa_visibility_icon(status)
case status.visibility
when 'public'
@ -143,10 +127,6 @@ module StatusesHelper
end
end
def rtl_size(words)
words.reduce(0) { |acc, elem| acc + elem.size }.to_f
end
def embedded_view?
params[:controller] == EMBEDDED_CONTROLLER && params[:action] == EMBEDDED_ACTION
end