ui: fix #74 (multi-lang edit for problem)

This commit is contained in:
undefined committed 2021-04-26 22:00:15 +08:00
1 parent ef5ee468bd
commit ebaa3f290b
10 files changed
+117 -85

No files matched your search

+4 -1
View File
@@ -142,8 +142,11 @@ class Nunjucks extends nunjucks.Environment {
s = content;
}
if (typeof s === 'object' && !(s instanceof Array)) {
const langs = Object.keys(s);
const f = langs.filter(i => i.startsWith(language));
if (s[language]) s = s[language];
else s = s[Object.keys(s)[0]];
else if (f.length) s = s[f[0]];
else s = s[langs[0]];
}
if (s instanceof Array) s = buildContent(s, html ? 'html' : 'markdown', (str) => str.translate(language));
return html ? xss.process(s) : markdown.render(s);