isodoc-i18n 1.0.3 → 1.0.4

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: e51e4427e97bf2e0fde14e6f995a35f56771180c5480de0231484927442aa80b
4
- data.tar.gz: 7516734ee389ab585094598bab5b8ecc696cf488f91cedf1454f192809dcb075
3
+ metadata.gz: d9ff88fde8b9dbc8298939de1c1952d05daa8d7651d04c80efa91c36e8b315fe
4
+ data.tar.gz: 86373bc0947b2de749b171a937195ed5e63a095b9346b65a8d3394270784faf6
5
5
  SHA512:
6
- metadata.gz: 876730b932cb38b6fcaa5af50e54b1a7f9b9be6c016ac0f82ad38fd00c0f510a15de812e09be5d733e81a6a16976cf547fc54a9cb113313c82e6762407a2e150
7
- data.tar.gz: cabf6cd3651fb0314a701d5bb08aafdd607eed4f90d2a2df74d7ea7895e4f90d6566abad20c56e816cdf9c247e865131a7d27cbd2ea258a4e9b171b6afbe9117
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.localize(tw_cldr_lang).to_rbnf_s(ord_class, @labels[ord_class])
154
+ tw_cldr_localize(num).to_rbnf_s(ord_class, @labels[ord_class])
155
155
  else
156
- num.localize(tw_cldr_lang)
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
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.0.3".freeze
3
+ VERSION = "1.0.4".freeze
4
4
  end
5
5
  end
@@ -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
@@ -30,7 +30,7 @@ def xmlpp(xml)
30
30
  end
31
31
 
32
32
  def metadata(hash)
33
- Hash[hash.sort].delete_if do |_k, v|
33
+ hash.sort.to_h.delete_if do |_k, v|
34
34
  v.nil? || (v.respond_to?(:empty?) && v.empty?)
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.