diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-31 11:41:35 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-31 11:41:35 +0200 |
commit | e87827a9215163948d0a68b9a33e56af8709762e (patch) | |
tree | 8d69bff6d7f39157738e789b2b2f521940da1bf3 | |
parent | 6ceb5f1ca33cc77922c6c34e31f174bf8e7ad991 (diff) | |
download | backoffice-e87827a9215163948d0a68b9a33e56af8709762e.tar.gz backoffice-e87827a9215163948d0a68b9a33e56af8709762e.tar.bz2 backoffice-e87827a9215163948d0a68b9a33e56af8709762e.zip |
i18n, first batch.
14 files changed, 397 insertions, 2 deletions
diff --git a/talerbackoffice/backoffice/static/logo-2018-dold.svg b/talerbackoffice/backoffice/static/logo-2018-dold.svg new file mode 100644 index 0000000..ddb8425 --- /dev/null +++ b/talerbackoffice/backoffice/static/logo-2018-dold.svg @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + viewBox="0 0 180 40" + version="1.1" + id="svg14" + sodipodi:docname="logo-2018-dold.svg" + inkscape:version="0.92.2 2405546, 2018-03-11"> + <metadata + id="metadata20"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs18" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1916" + inkscape:window-height="1041" + id="namedview16" + showgrid="false" + inkscape:zoom="1.8833333" + inkscape:cx="91.061947" + inkscape:cy="20" + inkscape:window-x="0" + inkscape:window-y="18" + inkscape:window-maximized="0" + inkscape:current-layer="text12" /> + <style + id="style2"> + .ts1 { fill: #aa3939; letter-spacing:0; } + .ts2 { letter-spacing:0; } + </style> + <g + aria-label="❬Taler❭" + style="color:#ff0000;font-weight:bold;font-size:36px;font-family:'Lucida Console', Monaco, monospace;letter-spacing:0.2em" + id="text12"> + <path + d="M 15.978516,31.285156 H 12.234375 L 5.6953125,18.154297 12.234375,5.0058594 h 3.744141 L 9.4042969,18.154297 Z" + style="letter-spacing:0;fill:#aa3939" + id="path3725" /> + <path + d="M 35.085937,29 H 29.900391 V 7.2910156 h -6.66211 V 2.7558594 h 18.509766 v 4.5351562 h -6.66211 z" + style="" + id="path3727" /> + <path + d="m 62.817188,19.753906 q -2.882812,0 -4.02539,0.738281 -1.142578,0.738282 -1.142578,2.53125 0,1.335938 0.791015,2.126954 0.791016,0.791015 2.144531,0.791015 2.039063,0 3.164063,-1.529297 1.125,-1.546875 1.125,-4.30664 v -0.351563 z m 7.171875,-1.986328 V 29 h -5.115234 v -2.197266 q -0.931641,1.300782 -2.390625,2.003907 -1.458984,0.703125 -3.216797,0.703125 -3.357422,0 -5.238281,-1.775391 -1.863281,-1.775391 -1.863281,-4.957031 0,-3.445313 2.232421,-5.080078 2.232422,-1.652344 6.908204,-1.652344 h 3.568359 v -0.861328 q 0,-1.248047 -0.914063,-1.88086 -0.896484,-0.65039 -2.654296,-0.65039 -1.845704,0 -3.585938,0.474609 -1.722656,0.457031 -3.603516,1.476563 v -4.394532 q 1.705079,-0.7031246 3.462891,-1.037109 1.757813,-0.3339844 3.726563,-0.3339844 4.798828,0 6.732421,1.9511724 1.951172,1.951171 1.951172,6.978515 z" + style="" + id="path3729" /> + <path + d="M 86.171486,20.791016 V 5.6035156 H 80.950783 V 1.6484375 H 91.321877 V 20.791016 q 0,2.320312 0.720703,3.287109 0.720703,0.966797 2.443359,0.966797 H 98.59922 V 29 h -5.554687 q -3.673828,0 -5.273438,-1.898438 -1.599609,-1.898437 -1.599609,-6.310546 z" + style="" + id="path3731" /> + <path + d="m 127.59609,28.033203 q -1.79297,0.738281 -3.65625,1.107422 -1.86328,0.369141 -3.9375,0.369141 -4.93945,0 -7.55859,-2.636719 -2.60156,-2.654297 -2.60156,-7.628906 0,-4.816407 2.51367,-7.611328 2.51367,-2.7949224 6.85547,-2.7949224 4.37695,0 6.78515,2.6015624 2.42578,2.583985 2.42578,7.294922 v 2.091797 h -13.34179 q 0.0176,2.320312 1.37109,3.46289 1.35352,1.142579 4.04297,1.142579 1.77539,0 3.49805,-0.509766 1.72265,-0.509766 3.60351,-1.617188 z m -4.35937,-11.074219 q -0.0352,-2.039062 -1.05469,-3.076171 -1.00195,-1.054688 -2.9707,-1.054688 -1.77539,0 -2.83008,1.089844 -1.05469,1.072265 -1.24805,3.058593 z" + style="" + id="path3733" /> + <path + d="m 157.31367,14.744141 q -0.84375,-0.773438 -1.98632,-1.160157 -1.125,-0.386718 -2.47852,-0.386718 -1.63476,0 -2.86523,0.580078 -1.21289,0.5625 -1.88086,1.652344 -0.42188,0.667968 -0.59766,1.617187 -0.1582,0.949219 -0.1582,2.882812 V 29 h -5.15039 V 9.3125 h 5.15039 v 3.058594 q 0.75586,-1.6875 2.32031,-2.6015627 1.56445,-0.9316407 3.65625,-0.9316407 1.05469,0 2.05664,0.2636719 1.01953,0.2460938 1.93359,0.7382813 z" + style="letter-spacing:0" + id="path3735" /> + <path + d="m 164.43282,31.285156 6.55664,-13.130859 -6.53907,-13.1484376 h 3.72657 l 6.53906,13.1484376 -6.53906,13.130859 z" + style="letter-spacing:0;fill:#aa3939" + id="path3737" /> + </g> +</svg> diff --git a/talerbackoffice/backoffice/templates/backoffice.html b/talerbackoffice/backoffice/templates/backoffice.html.j2 index b95f501..063a28f 100644 --- a/talerbackoffice/backoffice/templates/backoffice.html +++ b/talerbackoffice/backoffice/templates/backoffice.html.j2 @@ -1,9 +1,9 @@ {% extends "templates/base.html" %} {% block main %} <h1 class="logo-text">Taler backoffice</h1> - <p>This is the Taler backoffice facility. Through it, + <p>{% trans %}This is the Taler backoffice facility. Through it, the user can see the money flow from Taler transactions to - wire transfers and viceversa.</p> + wire transfers and viceversa.{% endtrans %}</p> <div id="information-bar"> <!-- programmatically filled. --> diff --git a/talerbackoffice/backoffice/templates/base.html b/talerbackoffice/backoffice/templates/base.html.j2 index 4e8109c..4e8109c 100644 --- a/talerbackoffice/backoffice/templates/base.html +++ b/talerbackoffice/backoffice/templates/base.html.j2 diff --git a/talerbackoffice/backoffice/templates/i18nfix.py b/talerbackoffice/backoffice/templates/i18nfix.py new file mode 100644 index 0000000..331706a --- /dev/null +++ b/talerbackoffice/backoffice/templates/i18nfix.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# This file is in the public domain. + +""" +Extract translations from a Jinja2 template, stripping leading newlines. + +@author Florian Dold +""" + +import jinja2.ext +import re + +def normalize(message): + message = message.strip() + # collapse whitespaces (including newlines) into one space. + message = re.sub("\s+", " ", message) + return message + + +def babel_extract(fileobj, keywords, comment_tags, options): + res = jinja2.ext.babel_extract(fileobj, keywords, comment_tags, options) + for lineno, funcname, message, comments in res: + message = normalize(message) + yield lineno, funcname, message, comments + +def wrap_gettext(f): + """ + Call gettext with whitespace normalized. + """ + def wrapper(message): + message = normalize(message) + return f(message) + return wrapper diff --git a/talerbackoffice/backoffice/templates/javascript.html b/talerbackoffice/backoffice/templates/javascript.html.j2 index 8f27425..8f27425 100644 --- a/talerbackoffice/backoffice/templates/javascript.html +++ b/talerbackoffice/backoffice/templates/javascript.html.j2 diff --git a/talerbackoffice/backoffice/templates/locale/babel.map b/talerbackoffice/backoffice/templates/locale/babel.map new file mode 100644 index 0000000..72b6f99 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/babel.map @@ -0,0 +1,12 @@ +[extractors] +jinja2 = i18nfix:babel_extract + +[jinja2: **.j2] +encoding = utf-8 +lstrip_blocks = True +trim_blocks = True + +[jinja2: **.j2.inc] +encoding = utf-8 +lstrip_blocks = True +ltrim_blocks = True diff --git a/talerbackoffice/backoffice/templates/locale/de/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/de/LC_MESSAGES/messages.po new file mode 100644 index 0000000..4b63635 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/de/LC_MESSAGES/messages.po @@ -0,0 +1,25 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <marko@mansarda>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: German\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" diff --git a/talerbackoffice/backoffice/templates/locale/en/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/en/LC_MESSAGES/messages.po new file mode 100644 index 0000000..839d17f --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/en/LC_MESSAGES/messages.po @@ -0,0 +1,27 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <stanisci.m@gmail.com>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: English\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." diff --git a/talerbackoffice/backoffice/templates/locale/fr/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/fr/LC_MESSAGES/messages.po new file mode 100644 index 0000000..8baa214 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/fr/LC_MESSAGES/messages.po @@ -0,0 +1,25 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <stanisci.m@gmail.com>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: French\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" diff --git a/talerbackoffice/backoffice/templates/locale/it/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/it/LC_MESSAGES/messages.po new file mode 100644 index 0000000..c017fc7 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/it/LC_MESSAGES/messages.po @@ -0,0 +1,25 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <stanisci.m@gmail.com>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: Italian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" diff --git a/talerbackoffice/backoffice/templates/locale/messages.pot b/talerbackoffice/backoffice/templates/locale/messages.pot new file mode 100644 index 0000000..9400cb4 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/messages.pot @@ -0,0 +1,25 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2018. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" + diff --git a/talerbackoffice/backoffice/templates/locale/pt/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/pt/LC_MESSAGES/messages.po new file mode 100644 index 0000000..603e0e8 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/pt/LC_MESSAGES/messages.po @@ -0,0 +1,25 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <stanisci.m@gmail.com>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: Portuguese\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: pt\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" diff --git a/talerbackoffice/backoffice/templates/locale/ru/LC_MESSAGES/messages.po b/talerbackoffice/backoffice/templates/locale/ru/LC_MESSAGES/messages.po new file mode 100644 index 0000000..1bb3f01 --- /dev/null +++ b/talerbackoffice/backoffice/templates/locale/ru/LC_MESSAGES/messages.po @@ -0,0 +1,26 @@ +# Translations template for PROJECT. +# Copyright (C) 2018 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# Marko Stanisky <stanisci.m@gmail.com>, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2018-07-31 11:29+0200\n" +"PO-Revision-Date: 2018-07-31 11:37+0200\n" +"Last-Translator: Marcello Stanisci <stanisci.m@gmail.com>\n" +"Language-Team: Russian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Language: ru\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#: backoffice.html.j2:4 +msgid "" +"This is the Taler backoffice facility. Through it, the user can see the " +"money flow from Taler transactions to wire transfers and viceversa." +msgstr "" diff --git a/talerbackoffice/backoffice/templates/template.py b/talerbackoffice/backoffice/templates/template.py new file mode 100755 index 0000000..eae04eb --- /dev/null +++ b/talerbackoffice/backoffice/templates/template.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# This file is in the public domain. +# +# This script runs the jinja2 templating engine on an input template-file +# using the specified locale for gettext translations, and outputs +# the resulting (HTML) ouptut-file. +# +# Note that the gettext files need to be prepared first. This script +# is thus to be invoked via the Makefile. +import os +import os.path +import sys +import re +import gettext +import jinja2 +import glob +import codecs +import os +sys.path.append(os.getcwd()) +import i18nfix + +env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), + extensions=["jinja2.ext.i18n"], + lstrip_blocks=True, + trim_blocks=True, + undefined=jinja2.StrictUndefined, + autoescape=False) + +langs_full = {"en": "English", + "fr": "Français", + "it": "Italiano", + "es": "Español", + "de": "Deutsch", + "ru": "Ру́сский язы́к", + "pt": "Português"} + +for in_file in glob.glob("*.j2"): + name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups() + tmpl = env.get_template(in_file) + + def self_localized(other_locale): + """ + Return URL for the current page in another locale. + """ + return "../" + other_locale + "/" + in_file.rstrip(".j2") + + def url_localized(filename): + return "../" + locale + "/" + filename + + def svg_localized(filename): + lf = filename + "." + locale + ".svg" + if "en" == locale or not os.path.isfile (lf): + return "../" + filename + ".svg" + else: + return "../" + lf + + def url(x): + # TODO: look at the app root environment variable + # TODO: check if file exists + return "../" + x + + for l in glob.glob("locale/*/"): + locale = os.path.basename(l[:-1]) + + tr = gettext.translation("messages", + localedir="locale", + languages=[locale]) + + tr.gettext = i18nfix.wrap_gettext(tr.gettext) + + env.install_gettext_translations(tr, newstyle=True) + + + content = tmpl.render( + lang=locale, + lang_full=langs_full[locale], + url=url, + self_localized=self_localized, + url_localized=url_localized, + svg_localized=svg_localized, + filename=name + "." + ext) + out_name = "./" + locale + "/" + in_file.rstrip(".j2") + os.makedirs("./" + locale, exist_ok=True) + with codecs.open(out_name, "w", "utf-8") as f: + f.write(content) |