isodoc-i18n 1.1.4 → 1.1.6
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/version.rb +1 -1
- data/lib/isodoc/i18n.rb +22 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf80de5e127891bdd42fef149b032db2649100b48e3903255b8045021d11f8d7
|
4
|
+
data.tar.gz: cbb3b8f8791089bd9ec2e161a0d268ae02b3768338963181f452812110aa32bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6f9db2ae6a42c46dc8b8b6722daaf90b0bcfddd67d3eb244186c9d4e561d76019c837609cce2dcad35d7bf039393c8aaffeeb46e4249688a1c6b1330da2aee1
|
7
|
+
data.tar.gz: b79476f0ca524c142d0135de71206b6a137055286f214a94bbfc0d125d12a8d18a7357cb2162b6e75e3a8308c6b9d85005bd88bcdffc545c8764c22c55911e22
|
data/lib/isodoc/i18n/version.rb
CHANGED
data/lib/isodoc/i18n.rb
CHANGED
@@ -78,7 +78,7 @@ module IsoDoc
|
|
78
78
|
# function localising spaces and punctuation.
|
79
79
|
# Not clear if period needs to be localised for zh
|
80
80
|
def l10n(text, lang = @lang, script = @script, locale = @locale)
|
81
|
-
lang == "zh"
|
81
|
+
lang == "zh" and text = l10n_zh(text, script)
|
82
82
|
lang == "fr" && text = l10n_fr(text, locale || "FR")
|
83
83
|
bidiwrap(text, lang, script)
|
84
84
|
end
|
@@ -101,12 +101,12 @@ module IsoDoc
|
|
101
101
|
.default_script(@lang))]
|
102
102
|
end
|
103
103
|
|
104
|
-
def l10n_zh(text)
|
104
|
+
def l10n_zh(text, script = "Hans")
|
105
105
|
xml = Nokogiri::XML::DocumentFragment.parse(text)
|
106
106
|
xml.traverse do |n|
|
107
107
|
next unless n.text?
|
108
108
|
|
109
|
-
n.replace(cleanup_entities(
|
109
|
+
n.replace(l10_zh1(cleanup_entities(n.text, is_xml: false), script))
|
110
110
|
end
|
111
111
|
xml.to_xml(encoding: "UTF-8").gsub(/<b>/, "").gsub("</b>", "")
|
112
112
|
.gsub(/<\?[^>]+>/, "")
|
@@ -117,7 +117,7 @@ module IsoDoc
|
|
117
117
|
xml.traverse do |n|
|
118
118
|
next unless n.text?
|
119
119
|
|
120
|
-
n.replace(cleanup_entities(
|
120
|
+
n.replace(l10n_fr1(cleanup_entities(n.text, is_xml: false), locale))
|
121
121
|
end
|
122
122
|
xml.to_xml(encoding: "UTF-8")
|
123
123
|
end
|
@@ -126,17 +126,16 @@ module IsoDoc
|
|
126
126
|
"\\p{In Halfwidth And Fullwidth Forms}".freeze
|
127
127
|
|
128
128
|
# note: we can't differentiate comma from enumeration comma 、
|
129
|
-
def l10_zh1(text)
|
129
|
+
def l10_zh1(text, _script)
|
130
130
|
l10n_zh_remove_space(l10n_zh_punct(text))
|
131
131
|
end
|
132
132
|
|
133
133
|
def l10n_zh_punct(text)
|
134
|
-
["::", ",,", "
|
135
|
-
text = text.gsub(
|
136
|
-
text = text.gsub(/^#{Regexp.quote m[0]}/, m[1])
|
134
|
+
["::", ",,", "..", "))", "]]", "::", ";;", "??", "!!", "–~"].each do |m|
|
135
|
+
text = text.gsub(/#{Regexp.quote m[0]}/, m[1])
|
137
136
|
end
|
138
|
-
["((", "[
|
139
|
-
text = text.gsub(/#{Regexp.quote m[0]}
|
137
|
+
["((", "[["].each do |m|
|
138
|
+
text = text.gsub(/#{Regexp.quote m[0]}/, m[1])
|
140
139
|
end
|
141
140
|
text
|
142
141
|
end
|
@@ -167,11 +166,16 @@ module IsoDoc
|
|
167
166
|
.sub(/%2/, list[1])
|
168
167
|
else
|
169
168
|
@labels["multiple_#{conn}"]
|
170
|
-
.sub(/%1/, l10n(list[0..-2].join(
|
169
|
+
.sub(/%1/, l10n(list[0..-2].join(enum_comma), @lang, @script))
|
171
170
|
.sub(/%2/, list[-1])
|
172
171
|
end
|
173
172
|
end
|
174
173
|
|
174
|
+
def enum_comma
|
175
|
+
%w(Hans Hant).include?(@script) and return "、"
|
176
|
+
", "
|
177
|
+
end
|
178
|
+
|
175
179
|
def cleanup_entities(text, is_xml: true)
|
176
180
|
c = HTMLEntities.new
|
177
181
|
if is_xml
|
@@ -186,12 +190,13 @@ module IsoDoc
|
|
186
190
|
|
187
191
|
# ord class is either SpelloutRules or OrdinalRules
|
188
192
|
def inflect_ordinal(num, term, ord_class)
|
189
|
-
if @labels["ordinal_keys"].nil? || @labels["ordinal_keys"].empty?
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
193
|
+
lbl = if @labels["ordinal_keys"].nil? || @labels["ordinal_keys"].empty?
|
194
|
+
@labels[ord_class]
|
195
|
+
else @labels[ord_class][ordinal_key(term)]
|
196
|
+
end
|
197
|
+
tw_cldr_localize(num).to_rbnf_s(ord_class, lbl)
|
198
|
+
rescue StandardError
|
199
|
+
num.localize(@lang.to_sym).to_rbnf_s(ord_class, lbl)
|
195
200
|
end
|
196
201
|
|
197
202
|
def tw_cldr_localize(num)
|
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.6
|
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-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
- !ruby/object:Gem::Version
|
232
232
|
version: '0'
|
233
233
|
requirements: []
|
234
|
-
rubygems_version: 3.3.
|
234
|
+
rubygems_version: 3.3.26
|
235
235
|
signing_key:
|
236
236
|
specification_version: 4
|
237
237
|
summary: isodoc-i18n
|