Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/i18n liquid #49

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gemspec

eval_gemfile("Gemfile.devel") rescue nil

5 changes: 3 additions & 2 deletions lib/isodoc-yaml/i18n-ar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ date_formats:
date_time: to_long_s
ordinal_keys: []
OrdinalRules: digits-ordinal
edition_ordinal: "الطبعة؜ %Ordinal"
edition_ordinal: "الطبعة؜ {{ var1 | ordinal_num: 'edition', '' }}"
edition: الطبعة؜ ؜
draft: "مشروع؜ %؜"
editor:
Expand Down Expand Up @@ -46,5 +46,6 @@ q-open:
q-close:
inflection:
الطبعة؜:
gender: f
grammar:
gender: f

5 changes: 3 additions & 2 deletions lib/isodoc-yaml/i18n-de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ date_formats:
day_month_year: to_long_s
date_time: to_long_s
draft: "Entwurf %"
edition_ordinal: "% Ausg."
edition_ordinal: "{{ var1 }} Ausg."
ordinal_keys: []
edition: Ausgabe
editor:
Expand Down Expand Up @@ -45,5 +45,6 @@ size:
pl: "% Nr."
inflection:
Ausgabe:
gender: f
grammar:
gender: f

2 changes: 1 addition & 1 deletion lib/isodoc-yaml/i18n-en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ date_formats:
ordinal_keys: []
OrdinalRules: digits-ordinal
edition: edition
edition_ordinal: "%Ordinal edition"
edition_ordinal: "{{ var1 | ordinal_num: '', '' }} edition"
draft: "draft %"
editor:
sg: ed.
Expand Down
5 changes: 3 additions & 2 deletions lib/isodoc-yaml/i18n-es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ordinal_keys: [gender]
OrdinalRules:
m: digits-ordinal-masculine
f: digits-ordinal-feminine
edition_ordinal: "%Ordinal ed."
edition_ordinal: "{{ var1 | ordinal_num: 'edition', '' }} ed."
edition: edición
draft: "borrador %"
editor:
Expand Down Expand Up @@ -49,5 +49,6 @@ issue:

inflection:
edición:
gender: f
grammar:
gender: f

5 changes: 3 additions & 2 deletions lib/isodoc-yaml/i18n-fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ OrdinalRules:
f.sg: digits-ordinal-feminine
m.pl: digits-ordinal-masculine-plural
f.pl: digits-ordinal-feminine-plural
edition_ordinal: "%Ordinal édition"
edition_ordinal: "{{ var1 | ordinal_num: 'edition', '' }} édition"
edition: édition
draft: "brouillon %"
editor:
Expand Down Expand Up @@ -50,5 +50,6 @@ size:
pl: "% nᵒˢ"
inflection:
édition:
gender: f
grammar:
gender: f

2 changes: 1 addition & 1 deletion lib/isodoc-yaml/i18n-ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ date_formats:
ordinal_keys: []
OrdinalRules: digits-ordinal
edition: 版
edition_ordinal: "%Ordinal edition"
edition_ordinal: "{{ var1 | ordinal_num: 'edition', '' }} edition"
draft: "下書き %"
editor:
sg: 編
Expand Down
5 changes: 3 additions & 2 deletions lib/isodoc-yaml/i18n-ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SpelloutRules:
m.pl: spellout-ordinal-plural
f.pl: spellout-ordinal-plural
n.pl: spellout-ordinal-plural
edition_ordinal: "%Spellout издание"
edition_ordinal: "{{ var1 | ordinal_word: 'edition', '' }} издание"
edition: издание
draft: "проект %"
editor:
Expand Down Expand Up @@ -53,5 +53,6 @@ size:
pl: "% шт."
inflection:
издание:
gender: n
grammar:
gender: n

2 changes: 1 addition & 1 deletion lib/isodoc-yaml/i18n-zh-Hans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ date_formats:
date_time: to_long_s
ordinal_keys: []
OrdinalRules: digits-ordinal
edition_ordinal: "第%Ordinal版"
edition_ordinal: "第{{ var1 | ordinal_num: '', '' }}版"
edition: 版
draft: "草案%"
editor:
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc-yaml/i18n-zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ date_formats:
date_time: to_long_s
ordinal_keys: []
OrdinalRules: digits-ordinal
edition_ordinal: "第%Ordinal版"
edition_ordinal: "第{{ var1 | ordinal_num: '', '' }}版"
edition: 版
draft: "草案%"
editor:
Expand Down
15 changes: 1 addition & 14 deletions lib/relaton/render/fields/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,7 @@ def role_inflect(contribs, role)

def editionformat(edn, num)
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

def edition_translate1(num)
ruleset = case @r.i18n.edition_ordinal
when /%Spellout/ then "SpelloutRules"
when /%Ordinal/ then "OrdinalRules"
else "Digit"
end
ruleset == "Digit" and return num.to_s
ed = HTMLEntities.new.decode(@r.i18n.edition)
@r.i18n.inflect_ordinal(num, @r.i18n.get["inflection"]&.dig(ed) || {},
ruleset)
@r.i18n.populate("edition_ordinal", { "var1" => num || edn.to_i })
end

def draftformat(num, _hash)
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.3".freeze
VERSION = "0.6.4".freeze
end
end
2 changes: 1 addition & 1 deletion relaton-render.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "simplecov"

spec.add_dependency "isodoc-i18n", "~> 1.2.0"
spec.add_dependency "isodoc-i18n", "~> 1.2.1"
spec.add_dependency "liquid", "~> 5"
spec.add_dependency "nokogiri"
spec.add_dependency "relaton-bib", ">= 1.13.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

it "renders incollection, two authors, with Arabic internationalisation" do
output = <<~OUTPUT
<formattedref>RAMSEY, J. K. و W. C. MCGREW. Object play in great apes: Studies in nature and captivity. في: PELLEGRINI, Anthony D. و Peter Kenneth SMITH (محرران): «The nature of play: Great apes and humans» [electronic resource, 8vo]. ؜الطبعة؜ ٣؜. New York, NY: Guilford Press. 2005. ؜89–112 ص؜. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [ينظر: 3 سبتمبر 2019].</formattedref>
<formattedref>RAMSEY, J. K. و W. C. MCGREW. Object play in great apes: Studies in nature and captivity. في: PELLEGRINI, Anthony D. و Peter Kenneth SMITH (محرران): «The nature of play: Great apes and humans» [electronic resource, 8vo]. الطبعة؜ ٣. New York, NY: Guilford Press. 2005. ؜89–112 ص؜. <link target='https://eprints.soton.ac.uk/338791/'>https://eprints.soton.ac.uk/338791/</link>. [ينظر: 3 سبتمبر 2019].</formattedref>
OUTPUT
p = Relaton::Render::General.new(language: "ar")
expect(HTMLEntities.new.decode(p.render(input)))
Expand Down
4 changes: 2 additions & 2 deletions spec/render_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
.to be_equivalent_to output
end

it "processes capitalize_first" do
it "processes capitalize_first" do
input = <<~INPUT
<bibitem type="book">
<title>facets of algebraic geometry: a collection in honor of william fulton's 80th birthday</title>
Expand Down Expand Up @@ -408,7 +408,7 @@
date_time: "to_long_s" })
expect(p.render(input))
.to be_equivalent_to output
end
end

it "processes formatted initials" do
input = <<~INPUT
Expand Down
Loading