isodoc-i18n 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9ff88fde8b9dbc8298939de1c1952d05daa8d7651d04c80efa91c36e8b315fe
4
- data.tar.gz: 86373bc0947b2de749b171a937195ed5e63a095b9346b65a8d3394270784faf6
3
+ metadata.gz: '0702006206028e38503e71c72fc5763c9ddc78798c7db38485ce3db8d1c58b55'
4
+ data.tar.gz: d55ddad57f401360969c491fc1c8efaa0a375324a09b1a2e1afee31bf9e76156
5
5
  SHA512:
6
- metadata.gz: c62054bd0e4b0af305a0c8ead2a429d2ca7855f283e2f0a257c85be0fcb86d773d8e9da4f518d8985ea2f47a4cb0b493c51900aa595b9dd0c78430a669707488
7
- data.tar.gz: fcd6eb42c29bf00363526889e28ab49682a0c678fd88ec022c5385fbab5b3c49f84e41e17fe72a34a9b4abf0a93a566351e6f4420c55e94d738b01052bc3567d
6
+ metadata.gz: 3fa9c7108157ebf3e63d7bcba97e37b878527593d4462356d5f23e4d6350da37bb76e173ae165e75a86b025d5b09a193f0cde80505f50a47a5c3396e5323ff41
7
+ data.tar.gz: 30673e7993504c760358ef70aa18352eae6f5455098f5e86e07080af51fadd68014bc826f056bc5c28908e59651611a4ee4bdf7e2fed953f2bd03e38d050df8c
data/lib/isodoc/i18n.rb CHANGED
@@ -5,9 +5,10 @@ require "twitter_cldr"
5
5
 
6
6
  module IsoDoc
7
7
  class I18n
8
- def load_yaml(lang, script, i18nyaml = nil)
8
+ def load_yaml(lang, script, i18nyaml = nil, i18nhash = nil)
9
9
  ret = load_yaml1(lang, script)
10
10
  return normalise_hash(ret.merge(YAML.load_file(i18nyaml))) if i18nyaml
11
+ return normalise_hash(ret.merge(i18nhash)) if i18nhash
11
12
 
12
13
  normalise_hash(ret)
13
14
  end
@@ -53,10 +54,10 @@ module IsoDoc
53
54
  @labels[key] = val
54
55
  end
55
56
 
56
- def initialize(lang, script, i18nyaml = nil)
57
+ def initialize(lang, script, i18nyaml: nil, i18nhash: nil)
57
58
  @lang = lang
58
59
  @script = script
59
- y = load_yaml(lang, script, i18nyaml)
60
+ y = load_yaml(lang, script, i18nyaml, i18nhash)
60
61
  @labels = y
61
62
  @labels["language"] = @lang
62
63
  @labels["script"] = @script
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.0.4".freeze
3
+ VERSION = "1.0.5".freeze
4
4
  end
5
5
  end
@@ -30,7 +30,15 @@ RSpec.describe IsoDoc::I18n do
30
30
  end
31
31
 
32
32
  it "loads language file overrides" do
33
- c = IsoDoc::I18n.new("en", "Latn", "spec/assets/new.yaml")
33
+ c = IsoDoc::I18n.new("en", "Latn", i18nyaml: "spec/assets/new.yaml")
34
+ expect(c.text).to eq "text2"
35
+ expect(c.at).to eq "at"
36
+ expect(c.hash.to_s).to be_equivalent_to '{"key1"=>"val1", "key2"=>"val2"}'
37
+ expect(c.arr.to_s).to eq '["arr1", "arr2"]'
38
+ end
39
+
40
+ it "loads language hash overrides" do
41
+ c = IsoDoc::I18n.new("en", "Latn", i18nhash: YAML.load_file("spec/assets/new.yaml"))
34
42
  expect(c.text).to eq "text2"
35
43
  expect(c.at).to eq "at"
36
44
  expect(c.hash.to_s).to be_equivalent_to '{"key1"=>"val1", "key2"=>"val2"}'
@@ -87,21 +95,21 @@ RSpec.describe IsoDoc::I18n do
87
95
  end
88
96
 
89
97
  it "does German ordinals" do
90
- c = IsoDoc::I18n.new("de", "Latn", "spec/assets/de.yaml")
98
+ c = IsoDoc::I18n.new("de", "Latn", i18nyaml: "spec/assets/de.yaml")
91
99
  term = c.inflection[c.edition]
92
100
  expect(c.inflect_ordinal(5, term, "SpelloutRules"))
93
101
  .to eq "fünfte"
94
102
  end
95
103
 
96
104
  it "does Chinese ordinals" do
97
- c = IsoDoc::I18n.new("zh", "Hans", "spec/assets/zh-Hans.yaml")
105
+ c = IsoDoc::I18n.new("zh", "Hans", i18nyaml: "spec/assets/zh-Hans.yaml")
98
106
  term = c.inflection[c.edition]
99
107
  expect(c.inflect_ordinal(5, term, "SpelloutRules"))
100
108
  .to eq "第五"
101
109
  end
102
110
 
103
111
  it "does Klingon ordinals" do
104
- c = IsoDoc::I18n.new("tlh", "Hans", "spec/assets/zh-Hans.yaml")
112
+ c = IsoDoc::I18n.new("tlh", "Hans", i18nyaml: "spec/assets/zh-Hans.yaml")
105
113
  term = c.inflection[c.edition]
106
114
  expect(c.inflect_ordinal(5, term, "SpelloutRules"))
107
115
  .to eq "fifth"
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
4
+ version: 1.0.5
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-04-27 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities