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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cb9429df0523ad853ce2c16221b6ca2da9df7f12be71ec1d9d31dfe8a4507c7
4
- data.tar.gz: 0a454f447146ec95be0a421d3b38844d3c502aabf998cef8dfa9158e731e65de
3
+ metadata.gz: 3b58388b8a4b834da128338007435231b542c8ba1bb8a132ad60e8d301d0f5d1
4
+ data.tar.gz: 1991032f0c7eb5af4f933e48bcb22e24998d0195fb8de477cedb5b40e5010996
5
5
  SHA512:
6
- metadata.gz: 98607331dc8eea71395667abccf85d4e97ce7c91223ccc1e4b7bb860f596de4262cd642fa94d68693a9e77c61d045c402e6919e71b23a4571e519bc0e6fdcc92
7
- data.tar.gz: e69e12e61a39badb700850998267e473b5acbe51cf3f11de332ed6a08cc6e50b73de8c6811bcb998999b6b07739b78c390368cdeacd5ad4b6dcf97b55787d5f2
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
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
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.gsub(/ /, "").gsub(/:/, ":")
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 ""
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.0.0".freeze
3
+ VERSION = "1.0.1".freeze
4
4
  end
5
5
  end
@@ -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 "Codehelloworld.)"
52
- expect(c.l10n("<a>Code (he<b>l</b>lo, world.)</a>"))
53
- .to be_equivalent_to "<a>Code(hello、world.)</a>"
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.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-03-23 00:00:00.000000000 Z
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