Skip to content

Commit

Permalink
refactor i18n yaml to prevent overwriting parent non-English YAML wit…
Browse files Browse the repository at this point in the history
…h local English file: metanorma/isodoc#549
  • Loading branch information
opoudjis committed Nov 29, 2023
1 parent d2beacb commit 01301b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/i18n-yaml-inheritance"
15 changes: 8 additions & 7 deletions lib/isodoc/ietf/i18n.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module IsoDoc
module Ietf
class I18n < IsoDoc::I18n
def load_yaml1(lang, script)
y = if lang == "en"
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
else
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
end
super.deep_merge(y)
def load_file(fname)
f = File.join(File.dirname(__FILE__), fname)
File.exist?(f) ? YAML.load_file(f) : {}
end

def load_yaml1(lang, script)
y = load_file("i18n-#{yaml_lang(lang, script)}.yaml")
y.empty? ? load_file("i18n-en.yaml").merge(super) : super.deep_merge(y)
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions lib/metanorma/ietf/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@
<ref name="image"/>
</element>
</define>
<define name="depiction">
<element name="depiction">
<optional>
<attribute name="scope"/>
</optional>
<zeroOrMore>
<ref name="image"/>
</zeroOrMore>
</element>
</define>
<define name="NameWithVariants">
<element name="primary">
<ref name="LocalizedString"/>
Expand Down Expand Up @@ -760,6 +770,9 @@
<optional>
<ref name="validity"/>
</optional>
<optional>
<ref name="depiction"/>
</optional>
</define>
<define name="ReducedBibliographicItem">
<optional>
Expand Down

0 comments on commit 01301b4

Please sign in to comment.