isodoc-i18n 1.0.3 → 1.0.4
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 +8 -2
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/base_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9ff88fde8b9dbc8298939de1c1952d05daa8d7651d04c80efa91c36e8b315fe
|
4
|
+
data.tar.gz: 86373bc0947b2de749b171a937195ed5e63a095b9346b65a8d3394270784faf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c62054bd0e4b0af305a0c8ead2a429d2ca7855f283e2f0a257c85be0fcb86d773d8e9da4f518d8985ea2f47a4cb0b493c51900aa595b9dd0c78430a669707488
|
7
|
+
data.tar.gz: fcd6eb42c29bf00363526889e28ab49682a0c678fd88ec022c5385fbab5b3c49f84e41e17fe72a34a9b4abf0a93a566351e6f4420c55e94d738b01052bc3567d
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -151,13 +151,19 @@ module IsoDoc
|
|
151
151
|
# ord class is either SpelloutRules or OrdinalRules
|
152
152
|
def inflect_ordinal(num, term, ord_class)
|
153
153
|
if @labels["ordinal_keys"].nil? || @labels["ordinal_keys"].empty?
|
154
|
-
num
|
154
|
+
tw_cldr_localize(num).to_rbnf_s(ord_class, @labels[ord_class])
|
155
155
|
else
|
156
|
-
num
|
156
|
+
tw_cldr_localize(num)
|
157
157
|
.to_rbnf_s(ord_class, @labels[ord_class][ordinal_key(term)])
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
def tw_cldr_localize(num)
|
162
|
+
num.localize(tw_cldr_lang)
|
163
|
+
rescue StandardError
|
164
|
+
num.localize(:en)
|
165
|
+
end
|
166
|
+
|
161
167
|
def ordinal_key(term)
|
162
168
|
@labels["ordinal_keys"].each_with_object([]) do |k, m|
|
163
169
|
m << case k
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/base_spec.rb
CHANGED
@@ -99,4 +99,11 @@ RSpec.describe IsoDoc::I18n do
|
|
99
99
|
expect(c.inflect_ordinal(5, term, "SpelloutRules"))
|
100
100
|
.to eq "第五"
|
101
101
|
end
|
102
|
+
|
103
|
+
it "does Klingon ordinals" do
|
104
|
+
c = IsoDoc::I18n.new("tlh", "Hans", "spec/assets/zh-Hans.yaml")
|
105
|
+
term = c.inflection[c.edition]
|
106
|
+
expect(c.inflect_ordinal(5, term, "SpelloutRules"))
|
107
|
+
.to eq "fifth"
|
108
|
+
end
|
102
109
|
end
|
data/spec/spec_helper.rb
CHANGED