summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-07-25 21:31:22 -0400
committerrsiddharth <s@ricketyspace.net>2020-07-25 21:31:22 -0400
commitee14e4300f48b69a4711226db33e794e9db170af (patch)
treeea0272292b5dea22f814b6ef25f3d0f822916e1a /bin
parent4446762982ae925916d4ab829580b44859940507 (diff)
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.
Diffstat (limited to 'bin')
-rw-r--r--bin/html9
1 files changed, 7 insertions, 2 deletions
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: