fix RTL reverse
This commit is contained in:
@@ -41,6 +41,7 @@ gem 'sidekiq', require: ENV.key?('REDIS_URL')
|
|||||||
gem 'sqlite3', require: false
|
gem 'sqlite3', require: false
|
||||||
gem 'strip_attributes'
|
gem 'strip_attributes'
|
||||||
gem 'turbo-rails'
|
gem 'turbo-rails'
|
||||||
|
gem 'twitter_cldr', require: false
|
||||||
gem 'tzinfo-data'
|
gem 'tzinfo-data'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ GEM
|
|||||||
bullet (7.1.4)
|
bullet (7.1.4)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
uniform_notifier (~> 1.11)
|
uniform_notifier (~> 1.11)
|
||||||
|
camertron-eprun (1.1.1)
|
||||||
cancancan (3.5.0)
|
cancancan (3.5.0)
|
||||||
capybara (3.39.2)
|
capybara (3.39.2)
|
||||||
addressable
|
addressable
|
||||||
@@ -136,6 +137,7 @@ GEM
|
|||||||
regexp_parser (>= 1.5, < 3.0)
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
chunky_png (1.4.0)
|
chunky_png (1.4.0)
|
||||||
|
cldr-plurals-runtime-rb (1.1.0)
|
||||||
cmdparse (3.0.7)
|
cmdparse (3.0.7)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
concurrent-ruby (1.2.2)
|
concurrent-ruby (1.2.2)
|
||||||
@@ -527,6 +529,10 @@ GEM
|
|||||||
actionpack (>= 6.0.0)
|
actionpack (>= 6.0.0)
|
||||||
activejob (>= 6.0.0)
|
activejob (>= 6.0.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
|
twitter_cldr (6.12.0)
|
||||||
|
camertron-eprun
|
||||||
|
cldr-plurals-runtime-rb (~> 1.1)
|
||||||
|
tzinfo
|
||||||
tzinfo (2.0.6)
|
tzinfo (2.0.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
tzinfo-data (1.2023.4)
|
tzinfo-data (1.2023.4)
|
||||||
@@ -612,6 +618,7 @@ DEPENDENCIES
|
|||||||
sqlite3
|
sqlite3
|
||||||
strip_attributes
|
strip_attributes
|
||||||
turbo-rails
|
turbo-rails
|
||||||
|
twitter_cldr
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
web-console
|
web-console
|
||||||
webmock
|
webmock
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'twitter_cldr/shared/bidi'
|
||||||
|
require 'twitter_cldr/shared/code_point'
|
||||||
|
require 'twitter_cldr/resources/loader'
|
||||||
|
|
||||||
|
module TwitterCldr
|
||||||
|
RESOURCES_DIR = File.join(Gem::Specification.find_by_name('twitter_cldr').gem_dir, 'resources')
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def resources
|
||||||
|
@resources ||= TwitterCldr::Resources::Loader.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_resource(...)
|
||||||
|
resources.get_resource(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -300,7 +300,9 @@ module Submissions
|
|||||||
|
|
||||||
def maybe_rtl_reverse(text)
|
def maybe_rtl_reverse(text)
|
||||||
if text.match?(RTL_REGEXP)
|
if text.match?(RTL_REGEXP)
|
||||||
ArabicLetterConnector.transform(text).reverse
|
TwitterCldr::Shared::Bidi
|
||||||
|
.from_string(ArabicLetterConnector.transform(text), direction: :RTL)
|
||||||
|
.reorder_visually!.to_s
|
||||||
else
|
else
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module Submissions
|
|||||||
SIGN_REASON = 'Signed by %<name>s with DocuSeal.co'
|
SIGN_REASON = 'Signed by %<name>s with DocuSeal.co'
|
||||||
SIGN_SIGNLE_REASON = 'Digitally signed with DocuSeal.co'
|
SIGN_SIGNLE_REASON = 'Digitally signed with DocuSeal.co'
|
||||||
|
|
||||||
RTL_REGEXP = /\A[\p{Hebrew}\p{Arabic}].*[\p{Hebrew}\p{Arabic}]\z/
|
RTL_REGEXP = /[\p{Hebrew}\p{Arabic}]/
|
||||||
|
|
||||||
TEXT_LEFT_MARGIN = 1
|
TEXT_LEFT_MARGIN = 1
|
||||||
TEXT_TOP_MARGIN = 1
|
TEXT_TOP_MARGIN = 1
|
||||||
@@ -320,7 +320,9 @@ module Submissions
|
|||||||
|
|
||||||
def maybe_rtl_reverse(text)
|
def maybe_rtl_reverse(text)
|
||||||
if text.match?(RTL_REGEXP)
|
if text.match?(RTL_REGEXP)
|
||||||
ArabicLetterConnector.transform(text).reverse
|
TwitterCldr::Shared::Bidi
|
||||||
|
.from_string(ArabicLetterConnector.transform(text), direction: :RTL)
|
||||||
|
.reorder_visually!.to_s
|
||||||
else
|
else
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user