Skip to content

Commit 52f2d68

Browse files
committed
refactor i18n yaml to prevent overwriting parent non-English YAML with local English file: metanorma/isodoc#549
1 parent c9d5ece commit 52f2d68

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Gemfile.devel

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/recursive-prefix-container"
1+
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/i18n-yaml-inheritance"

lib/isodoc/ogc/i18n.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
module IsoDoc
22
module Ogc
33
class I18n < IsoDoc::I18n
4+
def load_file(fname)
5+
f = File.join(File.dirname(__FILE__), fname)
6+
File.exist?(f) ? YAML.load_file(f) : {}
7+
end
8+
49
def load_yaml1(lang, script)
5-
y = YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
6-
super.deep_merge(y)
10+
y = load_file("i18n-#{yaml_lang(lang, script)}.yaml")
11+
y.empty? ? load_file("i18n-en.yaml").merge(super) : super.deep_merge(y)
712
end
813
end
914
end

0 commit comments

Comments
 (0)