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 +4 -4
- data/lib/isodoc/i18n.rb +4 -3
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/base_spec.rb +12 -4
- 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: '0702006206028e38503e71c72fc5763c9ddc78798c7db38485ce3db8d1c58b55'
|
4
|
+
data.tar.gz: d55ddad57f401360969c491fc1c8efaa0a375324a09b1a2e1afee31bf9e76156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/base_spec.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2022-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|