Skip to content

Commit af337ac

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

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Gemfile.devel

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

lib/isodoc/jis/i18n.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module IsoDoc
22
module JIS
33
class I18n < IsoDoc::Iso::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 = if lang == "en"
6-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
7-
else
8-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-ja.yaml"))
9-
end
10-
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)
1112
end
1213
end
1314
end
1415
end
15-

0 commit comments

Comments
 (0)