Skip to content

Commit

Permalink
More robust i18n of edition ordinals: metanorma/iso-5598#12
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Dec 14, 2023
1 parent 0caaaaf commit 7f5857d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/isodoc-yaml/i18n-de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ date_formats:
day_month_year: to_long_s
date_time: to_long_s
draft: "Entwurf %"
edition_ordinal: "% Aufl."
edition_ordinal: "% Ausg."
ordinal_keys: []
edition: Auflage
edition: Ausgabe
editor:
sg: Hrsg.
pl: Hrsg.
Expand Down Expand Up @@ -44,6 +44,6 @@ size:
sg: "% Nr."
pl: "% Nr."
inflection:
Auflage:
Ausgabe:
gender: f

5 changes: 2 additions & 3 deletions lib/relaton/render/fields/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ def role_inflect(contribs, role)
end

def editionformat(edn, num)
return edn unless num || /^\d+$/.match?(edn)

ret = edition_translate1(num || edn.to_i)
num || /^\d+$/.match?(edn) or return edn
ret = edition_translate1(num || edn.to_i) or return edn
@r.edition_ordinal.sub(/%(Spellout|Ordinal)?/, ret)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/relaton/render/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Relaton
module Render
VERSION = "0.6.2".freeze
VERSION = "0.6.3".freeze
end
end
4 changes: 2 additions & 2 deletions spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

it "renders incollection, two authors, with German internationalisation" do
output = <<~OUTPUT
<formattedref>RAMSEY, J. K. und W. C. MCGREW. Object play in great apes: Studies in nature and captivity. In: PELLEGRINI, Anthony D. und Peter Kenneth SMITH (Hrsg.): <em>The nature of play: Great apes and humans</em> [electronic resource, 8vo]. 3 Aufl. New York, NY: Guilford Press. 2005. S. 89–112. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [angesehen: 3. September 2019].</formattedref>
<formattedref>RAMSEY, J. K. und W. C. MCGREW. Object play in great apes: Studies in nature and captivity. In: PELLEGRINI, Anthony D. und Peter Kenneth SMITH (Hrsg.): <em>The nature of play: Great apes and humans</em> [electronic resource, 8vo]. 3 Ausg. New York, NY: Guilford Press. 2005. S. 89–112. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [angesehen: 3. September 2019].</formattedref>
OUTPUT
p = Relaton::Render::General.new(language: "de")
expect(HTMLEntities.new.decode(p.render(input)))
Expand All @@ -95,7 +95,7 @@

it "renders incollection, two authors, with German internationalisation, with customisation of i18n" do
output = <<~OUTPUT
<formattedref>RAMSEY, J. K. and W. C. MCGREW. Object play in great apes: Studies in nature and captivity. In: PELLEGRINI, Anthony D. and Peter Kenneth SMITH (Hrsg.): <em>The nature of play: Great apes and humans</em> [electronic resource, 8vo]. 3 Aufl. New York, NY: Guilford Press. 2005. S. 89–112. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [angesehen: 3. September 2019].</formattedref>
<formattedref>RAMSEY, J. K. and W. C. MCGREW. Object play in great apes: Studies in nature and captivity. In: PELLEGRINI, Anthony D. and Peter Kenneth SMITH (Hrsg.): <em>The nature of play: Great apes and humans</em> [electronic resource, 8vo]. 3 Ausg. New York, NY: Guilford Press. 2005. S. 89–112. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [angesehen: 3. September 2019].</formattedref>
OUTPUT
p = Relaton::Render::General.new(language: "de",
i18nhash: { "author_and" => "and" })
Expand Down

0 comments on commit 7f5857d

Please sign in to comment.