diff options
author | rsiddharth <s@ricketyspace.net> | 2020-07-25 21:31:22 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-07-25 21:31:22 -0400 |
commit | ee14e4300f48b69a4711226db33e794e9db170af (patch) | |
tree | ea0272292b5dea22f814b6ef25f3d0f822916e1a | |
parent | 4446762982ae925916d4ab829580b44859940507 (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.
-rw-r--r-- | bin/html | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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: |