0
0
Fork 0

Fix #186 - Add RTL support to the compose form textarea and statuses output

This commit is contained in:
Eugen Rochko 2017-02-28 01:52:31 +01:00
parent 809455aaae
commit d180aaa2a7
6 changed files with 57 additions and 4 deletions

View file

@ -37,4 +37,17 @@ module StreamEntriesHelper
def proper_status(status)
status.reblog? ? status.reblog : status
end
def rtl?(text)
return false if text.empty?
matches = /[\p{Hebrew}|\p{Arabic}|\p{Syriac}|\p{Thaana}|\p{Nko}]+/m.match(text)
return false unless matches
rtl_size = matches.to_a.reduce(0) { |acc, elem| acc + elem.size }.to_f
ltr_size = text.strip.size.to_f
rtl_size / ltr_size > 0.3
end
end