mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: fix #74 (multi-lang edit for problem)
This commit is contained in:
1 parent
ef5ee468bd
commit
ebaa3f290b
10 files changed
+117
-85
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user