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 c2167ed commit 243fd0c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/isodoc/ieee/i18n.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
module IsoDoc
module IEEE
class I18n < IsoDoc::I18n
def load_yaml2x(str)
::YAML.load_file(File.join(File.dirname(__FILE__),
"i18n-#{str}.yaml"))
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 = case lang
when "en"
load_yaml2x(lang)
else load_yaml2x("en")
end
super.deep_merge(y)
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

0 comments on commit 243fd0c

Please sign in to comment.