From ee14e4300f48b69a4711226db33e794e9db170af Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 25 Jul 2020 21:31:22 -0400 Subject: add i18n support * bin/html (html): Add argument `lm` -- langmap and add handling to insert lang block if the news item is available in more than one language. (process): Generate language map via `langmap` and pass it to the `html` call. --- bin/html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin/html') diff --git a/bin/html b/bin/html index 14adba3..627cd83 100644 --- a/bin/html +++ b/bin/html @@ -158,7 +158,7 @@ def langhtml(sec, s, lng, lngs): return template('lang').replace(PH['lang'], ' | '.join(lsh), 1) -def html(sec, f): +def html(sec, f, lm): c = read(f.path) s, l = slug(f.path) @@ -175,6 +175,9 @@ def html(sec, f): if author: h = h.replace(PH['author'], a, 1) + if len(lm[s]) > 1: + h = h.replace(PH['lang'], langhtml(sec, s, l, lm[s]), 1) + return s, h, l @@ -197,8 +200,10 @@ def langmap(sec): def process(sec): + lm = langmap(sec) + for f in files(sec): - s, h, l = html(sec, f) + s, h, l = html(sec, f, lm) if not l: write('/'.join(['_build', sec, s, 'index.html']), h) else: -- cgit v1.2.3