mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
text utils for RTL
This commit is contained in:
1 parent
98f5bba832
commit
f1ebd8f912
5 files changed
+26
-29
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module TextUtils
|
||||
RTL_REGEXP = /[\p{Hebrew}\p{Arabic}]/
|
||||
|
||||
module_function
|
||||
|
||||
def maybe_rtl_reverse(text)
|
||||
if text.match?(RTL_REGEXP)
|
||||
TwitterCldr::Shared::Bidi
|
||||
.from_string(ArabicLetterConnector.transform(text), direction: :RTL)
|
||||
.reorder_visually!.to_s
|
||||
else
|
||||
text
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user