diff --git a/Gemfile.devel b/Gemfile.devel index 4d0eb15..e3a37c0 100644 --- a/Gemfile.devel +++ b/Gemfile.devel @@ -1 +1 @@ -gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/recursive-prefix-container" +gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/i18n-yaml-inheritance" diff --git a/lib/isodoc/ieee/i18n.rb b/lib/isodoc/ieee/i18n.rb index ad438fd..e5ab63a 100644 --- a/lib/isodoc/ieee/i18n.rb +++ b/lib/isodoc/ieee/i18n.rb @@ -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