|
|
@ -53,11 +53,11 @@ module StreamEntriesHelper
|
|
|
|
|
|
|
|
|
|
|
|
def rtl?(text)
|
|
|
|
def rtl?(text)
|
|
|
|
text = simplified_text(text)
|
|
|
|
text = simplified_text(text)
|
|
|
|
rtl_characters = /[\p{Hebrew}|\p{Arabic}|\p{Syriac}|\p{Thaana}|\p{Nko}]+/m.match(text)
|
|
|
|
rtl_words = text.scan(/[\p{Hebrew}\p{Arabic}\p{Syriac}\p{Thaana}\p{Nko}]+/m)
|
|
|
|
|
|
|
|
|
|
|
|
if rtl_characters.present?
|
|
|
|
if rtl_words.present?
|
|
|
|
total_size = text.size.to_f
|
|
|
|
total_size = text.size.to_f
|
|
|
|
rtl_size(rtl_characters.to_a) / total_size > 0.3
|
|
|
|
rtl_size(rtl_words) / total_size > 0.3
|
|
|
|
else
|
|
|
|
else
|
|
|
|
false
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -77,8 +77,8 @@ module StreamEntriesHelper
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def rtl_size(characters)
|
|
|
|
def rtl_size(words)
|
|
|
|
characters.reduce(0) { |acc, elem| acc + elem.size }.to_f
|
|
|
|
words.reduce(0) { |acc, elem| acc + elem.size }.to_f
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def embedded_view?
|
|
|
|
def embedded_view?
|
|
|
|