refactor: merge into per-language i18n files
This commit is contained in:
parent
b63b880116
commit
9b7800aa8c
|
@ -3,10 +3,14 @@
|
||||||
-mode(compile).
|
-mode(compile).
|
||||||
|
|
||||||
main(_) ->
|
main(_) ->
|
||||||
|
main_per_lang("en"),
|
||||||
|
main_per_lang("zh").
|
||||||
|
|
||||||
|
main_per_lang(Lang) ->
|
||||||
BaseConf = <<"">>,
|
BaseConf = <<"">>,
|
||||||
Cfgs0 = get_all_files(),
|
Cfgs0 = get_all_files(Lang),
|
||||||
Conf = merge(BaseConf, Cfgs0),
|
Conf = merge(BaseConf, Cfgs0),
|
||||||
OutputFile = "apps/emqx_dashboard/priv/i18n.conf",
|
OutputFile = "apps/emqx_dashboard/priv/i18n." ++ Lang ++ ".conf",
|
||||||
ok = filelib:ensure_dir(OutputFile),
|
ok = filelib:ensure_dir(OutputFile),
|
||||||
ok = file:write_file(OutputFile, Conf).
|
ok = file:write_file(OutputFile, Conf).
|
||||||
|
|
||||||
|
@ -21,7 +25,11 @@ merge(BaseConf, Cfgs) ->
|
||||||
end
|
end
|
||||||
end, BaseConf, Cfgs).
|
end, BaseConf, Cfgs).
|
||||||
|
|
||||||
get_all_files() ->
|
get_all_files(Lang) ->
|
||||||
Dir = filename:join(["rel","i18n"]),
|
Dir =
|
||||||
|
case Lang of
|
||||||
|
"en" -> filename:join(["rel", "i18n"]);
|
||||||
|
"zh" -> filename:join(["rel", "i18n", "zh"])
|
||||||
|
end,
|
||||||
Files = filelib:wildcard("*.hocon", Dir),
|
Files = filelib:wildcard("*.hocon", Dir),
|
||||||
lists:map(fun(Name) -> filename:join([Dir, Name]) end, Files).
|
lists:map(fun(Name) -> filename:join([Dir, Name]) end, Files).
|
||||||
|
|
Loading…
Reference in New Issue