isodoc-i18n 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +15 -0
- data/.hound.yml +5 -0
- data/lib/isodoc/i18n.rb +15 -3
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/base_spec.rb +5 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b58388b8a4b834da128338007435231b542c8ba1bb8a132ad60e8d301d0f5d1
|
4
|
+
data.tar.gz: 1991032f0c7eb5af4f933e48bcb22e24998d0195fb8de477cedb5b40e5010996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c448bcb7fc53efca80380ba2a0e1f187114c94c2fba7aa8bb00219bb53adcd1be1a92f1e1858f1dc0626ab0c1de1572221954a044967eb284326ce9e3c0ec483
|
7
|
+
data.tar.gz: 97cde46c476699cf091b2cb175aac1b578e206df016ed9df17027bf3381c2b1b41451aa3a1c62bae89b4d444037055d3f3b59eefe9978eb2ed9aca23d8ad3a38
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
data/.hound.yml
ADDED
data/lib/isodoc/i18n.rb
CHANGED
@@ -100,13 +100,25 @@ module IsoDoc
|
|
100
100
|
xml.traverse do |n|
|
101
101
|
next unless n.text?
|
102
102
|
|
103
|
-
n.replace(cleanup_entities(n.text
|
104
|
-
.gsub(/,/, "、").gsub(/\(/, "(").gsub(/\)/, ")")
|
105
|
-
.gsub(/\[/, "【").gsub(/\]/, "】"), is_xml: false))
|
103
|
+
n.replace(cleanup_entities(l10_zh1(n.text), is_xml: false))
|
106
104
|
end
|
107
105
|
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
|
108
106
|
end
|
109
107
|
|
108
|
+
ZH_CHAR = "\\p{Han}|\\p{In CJK Symbols And Punctuation}|"\
|
109
|
+
"\\p{In Halfwidth And Fullwidth Forms}".freeze
|
110
|
+
|
111
|
+
# note: we can't differentiate comma from enumeration comma 、
|
112
|
+
def l10_zh1(text)
|
113
|
+
["::", ",,", ".。", "))", "]】", "::", ";;", "??", "!!"].each do |m|
|
114
|
+
text = text.gsub(/(?<=#{ZH_CHAR})#{Regexp.quote m[0]}/, m[1])
|
115
|
+
end
|
116
|
+
["((", "[【"].each do |m|
|
117
|
+
text = text.gsub(/#{Regexp.quote m[0]}(?=#{ZH_CHAR})/, m[1])
|
118
|
+
end
|
119
|
+
text.gsub(/(?<=#{ZH_CHAR}) (?=#{ZH_CHAR})/o, "")
|
120
|
+
end
|
121
|
+
|
110
122
|
def boolean_conj(list, conn)
|
111
123
|
case list.size
|
112
124
|
when 0 then ""
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/base_spec.rb
CHANGED
@@ -48,9 +48,11 @@ RSpec.describe IsoDoc::I18n do
|
|
48
48
|
it "does Chinese localisation" do
|
49
49
|
c = IsoDoc::I18n.new("zh", "Hans")
|
50
50
|
expect(c.l10n("Code (hello, world.)"))
|
51
|
-
.to be_equivalent_to "Code
|
52
|
-
expect(c.l10n("
|
53
|
-
.to be_equivalent_to "
|
51
|
+
.to be_equivalent_to "Code (hello, world.)"
|
52
|
+
expect(c.l10n("计算机代码 (你好, 世界.)"))
|
53
|
+
.to be_equivalent_to " 计算机代码(你好,世界。)"
|
54
|
+
expect(c.l10n("<a>计算机代码</a> (<b>你好,</b> 世界.)"))
|
55
|
+
.to be_equivalent_to "<a>计算机代码</a> (你好, 世界。)"
|
54
56
|
end
|
55
57
|
|
56
58
|
it "does Hebrew RTL localisation" 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.0.
|
4
|
+
version: 1.0.1
|
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
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -187,6 +187,8 @@ executables: []
|
|
187
187
|
extensions: []
|
188
188
|
extra_rdoc_files: []
|
189
189
|
files:
|
190
|
+
- ".github/workflows/rake.yml"
|
191
|
+
- ".hound.yml"
|
190
192
|
- ".rubocop.yml"
|
191
193
|
- CODE_OF_CONDUCT.md
|
192
194
|
- Gemfile
|