isodoc-i18n 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isodoc/i18n.rb +12 -9
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/base_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db66af34abba937daa72bbef574be08220618ca75b104c5b1e6275736494e781
|
4
|
+
data.tar.gz: b94275b875363991d526ea1a83ec3be97bdc93dcd0db16681cee8ba0197a8577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16e56e238e36071225875002eeb86959c23ddcf2ae874fa7db18e6893978e4d7105b88964867f8cd331718c975bdea5175845533e6ad045b621b035bff34a3c7
|
7
|
+
data.tar.gz: 87da9b7308403c25d52f8008177cb0ef62da042df0d58d8f26864678de53b84a925465dd36b9b40e1a106ca8a8406411d515567f1316903d54643cbbc89dc339
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -98,23 +98,24 @@ module IsoDoc
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def l10n_zh(text)
|
101
|
-
xml = Nokogiri::
|
101
|
+
xml = Nokogiri::XML::DocumentFragment.parse(text)
|
102
102
|
xml.traverse do |n|
|
103
103
|
next unless n.text?
|
104
104
|
|
105
105
|
n.replace(cleanup_entities(l10_zh1(n.text), is_xml: false))
|
106
106
|
end
|
107
|
-
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "")
|
107
|
+
xml.to_xml(encoding: "UTF-8").gsub(/<b>/, "").gsub("</b>", "")
|
108
|
+
.gsub(/<\?[^>]+>/, "")
|
108
109
|
end
|
109
110
|
|
110
111
|
def l10n_fr(text, locale)
|
111
|
-
xml = Nokogiri::
|
112
|
+
xml = Nokogiri::XML::DocumentFragment.parse(text)
|
112
113
|
xml.traverse do |n|
|
113
114
|
next unless n.text?
|
114
115
|
|
115
116
|
n.replace(cleanup_entities(l10n_fr1(n.text, locale), is_xml: false))
|
116
117
|
end
|
117
|
-
xml.to_xml
|
118
|
+
xml.to_xml(encoding: "UTF-8")
|
118
119
|
end
|
119
120
|
|
120
121
|
ZH_CHAR = "\\p{Han}|\\p{In CJK Symbols And Punctuation}|"\
|
@@ -144,12 +145,14 @@ module IsoDoc
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def l10n_fr1(text, locale)
|
147
|
-
text = text.gsub(/(?<=\p{Alnum})([»›;?!])/, "\u202f\\1")
|
148
|
+
text = text.gsub(/(?<=\p{Alnum})([»›;?!])(?=\s)/, "\u202f\\1")
|
149
|
+
text = text.gsub(/(?<=\p{Alnum})([»›;?!])$/, "\u202f\\1")
|
148
150
|
text = text.gsub(/^([»›;?!])/, "\u202f\\1")
|
149
151
|
text = text.gsub(/([«‹])/, "\\1\u202f")
|
150
152
|
colonsp = locale == "CH" ? "\u202f" : "\u00a0"
|
151
|
-
text = text.gsub(/(?<=\p{Alnum})(:)/, "#{colonsp}\\1")
|
152
|
-
text.gsub(
|
153
|
+
text = text.gsub(/(?<=\p{Alnum})(:)(?=\s)/, "#{colonsp}\\1")
|
154
|
+
text = text.gsub(/(?<=\p{Alnum})(:)$/, "#{colonsp}\\1")
|
155
|
+
text.gsub(/^(:\s)/, "#{colonsp}\\1")
|
153
156
|
end
|
154
157
|
|
155
158
|
def boolean_conj(list, conn)
|
@@ -169,11 +172,11 @@ module IsoDoc
|
|
169
172
|
c = HTMLEntities.new
|
170
173
|
if is_xml
|
171
174
|
text.split(/([<>])/).each_slice(4).map do |a|
|
172
|
-
a[0] = c.
|
175
|
+
a[0] = c.decode(a[0])
|
173
176
|
a
|
174
177
|
end.join
|
175
178
|
else
|
176
|
-
c.
|
179
|
+
c.decode(text)
|
177
180
|
end
|
178
181
|
end
|
179
182
|
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/base_spec.rb
CHANGED
@@ -103,6 +103,8 @@ RSpec.describe IsoDoc::I18n do
|
|
103
103
|
expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
|
104
104
|
.to be_equivalent_to "Code ; « code » "\
|
105
105
|
"and : code !"
|
106
|
+
expect(e.encode(c.l10n("http://xyz a;b"), :hexadecimal))
|
107
|
+
.to be_equivalent_to "http://xyz a;b"
|
106
108
|
end
|
107
109
|
|
108
110
|
it "does boolean conjunctions" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|