gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-www] 04/05: i18n: generate HTML files from templates


From: gnunet
Subject: [GNUnet-SVN] [taler-www] 04/05: i18n: generate HTML files from templates for each language
Date: Thu, 19 Jan 2017 19:24:31 +0100

This is an automated email from the git hooks/post-receive script.

tg pushed a commit to branch master
in repository www.

commit 856556bb33ed4bd881f9ed866696fc6c1e5af37f
Author: tg(x) <address@hidden>
AuthorDate: Thu Jan 19 18:54:35 2017 +0100

    i18n: generate HTML files from templates for each language
---
 Makefile    |  7 +++++--
 template.py | 29 +++++++++++++++++++++++++++++
 template.sh |  9 +++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b9a72a9..84bf821 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-all: locale
-       cd web-common && tsc taler-wallet-lib.ts && cd ..
+all: template
+       cd web-common && tsc taler-wallet-lib.ts
 
 locale/messages.pot: *.j2 common/*.j2
        pybabel extract -F locale/babel.map -o locale/messages.pot .
@@ -19,3 +19,6 @@ locale-compile: locale-update
        pybabel compile -d locale -l es --use-fuzzy
 
 locale: locale-compile
+
+template: locale
+       ./template.sh
diff --git a/template.py b/template.py
new file mode 100755
index 0000000..86516bb
--- /dev/null
+++ b/template.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import gettext
+import jinja2
+
+if len(sys.argv) < 3:
+    sys.exit("Usage: " + __file__ + " <template-file> <locale> <output-file>")
+
+in_file = sys.argv[1]
+locale = sys.argv[2]
+out_file = sys.argv[3]
+
+tr = gettext.translation("messages",
+                         localedir="locale",
+                         languages=[locale])
+
+env = 
jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
+                         extensions=["jinja2.ext.i18n"],
+                         autoescape=False)
+env.install_gettext_translations(tr, newstyle=True)
+
+tmpl = env.get_template(in_file)
+
+import codecs
+f = codecs.open(out_file, "w", "utf-8")
+f.write(tmpl.render())
+f.close()
diff --git a/template.sh b/template.sh
new file mode 100755
index 0000000..4d498c7
--- /dev/null
+++ b/template.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+for f in $(git ls-files *.j2 common/*.j2); do
+    for ld in locale/*/; do
+       l=$(basename $ld)
+       echo "$f: $l"
+       python template.py $f $l $(basename $f .html.j2).$l.html
+    done
+done

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]