gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-docs-landing] 01/04: i18n first batch.


From: gnunet
Subject: [GNUnet-SVN] [taler-docs-landing] 01/04: i18n first batch.
Date: Mon, 24 Sep 2018 15:54:27 +0200

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

marcello pushed a commit to branch master
in repository docs-landing.

commit 962b4771422fc7a0f649ec972ea52936358419cb
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Sep 24 15:05:34 2018 +0200

    i18n first batch.
---
 .gitignore                        | 10 ++++++
 Makefile                          | 32 +++++++++++++++++
 babel.map                         |  2 ++
 index.html => index.html.j2       |  2 +-
 locale/de/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/en/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/es/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/fr/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/it/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/messages.pot               | 27 ++++++++++++++
 locale/pt/LC_MESSAGES/messages.po | 19 ++++++++++
 locale/ru/LC_MESSAGES/messages.po | 20 +++++++++++
 template.py                       | 76 +++++++++++++++++++++++++++++++++++++++
 13 files changed, 282 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..992a847
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+**.mo
+**.po~
+de/*
+en/*
+es/*
+ru/*
+pt/*
+fr/*
+it/*
+*.swp
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..47bf5cc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
+
+
+# This file is in the public domain.
+
+.PHONY: extract
+
+# Extract translateable strings from jinja2 templates.
+extract: *.html
+       pybabel extract -F babel.map index.html.j2 -o locale/messages.pot .
+
+# Update translation (.po) files with new strings.
+update: locale/messages.pot
+       msgmerge -U -m --previous locale/en/LC_MESSAGES/messages.po 
locale/messages.pot 
+       msgmerge -U -m --previous locale/de/LC_MESSAGES/messages.po 
locale/messages.pot
+       msgmerge -U -m --previous locale/fr/LC_MESSAGES/messages.po 
locale/messages.pot
+       msgmerge -U -m --previous locale/es/LC_MESSAGES/messages.po 
locale/messages.pot
+       msgmerge -U -m --previous locale/it/LC_MESSAGES/messages.po 
locale/messages.pot
+       msgmerge -U -m --previous locale/ru/LC_MESSAGES/messages.po 
locale/messages.pot
+       msgmerge -U -m --previous locale/pt/LC_MESSAGES/messages.po 
locale/messages.pot
+
+# Compile translation files for use.
+compile:
+       pybabel compile -d locale -l en --use-fuzzy
+       pybabel compile -d locale -l de --use-fuzzy
+       pybabel compile -d locale -l fr --use-fuzzy
+       pybabel compile -d locale -l it --use-fuzzy
+       pybabel compile -d locale -l es --use-fuzzy
+       pybabel compile -d locale -l ru --use-fuzzy
+       pybabel compile -d locale -l pt --use-fuzzy
+
+translate:
+       ./template.py
diff --git a/babel.map b/babel.map
new file mode 100644
index 0000000..caf6dbe
--- /dev/null
+++ b/babel.map
@@ -0,0 +1,2 @@
+[jinja2: **.j2]
+extensions=jinja2.ext.autoescape,jinja2.ext.with_
diff --git a/index.html b/index.html.j2
similarity index 98%
rename from index.html
rename to index.html.j2
index c83ed86..0998cf2 100644
--- a/index.html
+++ b/index.html.j2
@@ -8,7 +8,7 @@
   </head>
   <body>
   <h1>GNU Taler documentation</h1>
-  This page is an overview of all documentation resources for <a 
href="https://taler.net";>GNU Taler</a>.
+  _("page is an overview of all documentation resources for") <a 
href="https://taler.net";>GNU Taler</a>.
 
   <h2>Components</h2>
 
diff --git a/locale/de/LC_MESSAGES/messages.po 
b/locale/de/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..687e69a
--- /dev/null
+++ b/locale/de/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# German translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: de <address@hidden>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/en/LC_MESSAGES/messages.po 
b/locale/en/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..de42756
--- /dev/null
+++ b/locale/en/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# English translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:48+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: en <address@hidden>\n"
+"Language: en\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/es/LC_MESSAGES/messages.po 
b/locale/es/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..1e19de7
--- /dev/null
+++ b/locale/es/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# Spanish translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: es <address@hidden>\n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/fr/LC_MESSAGES/messages.po 
b/locale/fr/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..55c9428
--- /dev/null
+++ b/locale/fr/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# French translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: fr <address@hidden>\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/it/LC_MESSAGES/messages.po 
b/locale/it/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..fe51543
--- /dev/null
+++ b/locale/it/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# Italian translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: it <address@hidden>\n"
+"Language: it\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/messages.pot b/locale/messages.pot
new file mode 100644
index 0000000..bf81efa
--- /dev/null
+++ b/locale/messages.pot
@@ -0,0 +1,27 @@
+# Translations template for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 15:00+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 2.5.1\n"
+
+#: index.html.j2:11
+msgid ""
+"\n"
+"  page is an overview of all documentation resources for <a "
+"href=\"https://taler.net\";>GNU Taler</a>.\n"
+"  "
+msgstr ""
+
diff --git a/locale/pt/LC_MESSAGES/messages.po 
b/locale/pt/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..66df273
--- /dev/null
+++ b/locale/pt/LC_MESSAGES/messages.po
@@ -0,0 +1,19 @@
+# Portuguese translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: pt <address@hidden>\n"
+"Language: pt\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Generated-By: Babel 2.5.1\n"
diff --git a/locale/ru/LC_MESSAGES/messages.po 
b/locale/ru/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..721a3a2
--- /dev/null
+++ b/locale/ru/LC_MESSAGES/messages.po
@@ -0,0 +1,20 @@
+# Russian translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <address@hidden>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"POT-Creation-Date: 2018-09-24 14:46+0200\n"
+"PO-Revision-Date: 2018-09-24 14:49+0200\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: ru <address@hidden>\n"
+"Language: ru\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\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"
+"Generated-By: Babel 2.5.1\n"
diff --git a/template.py b/template.py
new file mode 100755
index 0000000..cd122d3
--- /dev/null
+++ b/template.py
@@ -0,0 +1,76 @@
+#!/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
+import os.path
+
+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)
+
+default_ctx = {}
+default_ctx["custom_link"] = os.environ.get("TALER_ENV_URL_CUSTOMLINK", "#")
+
+
+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 url(x):
+        # TODO: look at the app root environment variable
+        # TODO: check if file exists
+        return "../" + x
+
+    for l in ("en", "de", "it", "es"):
+        locale = os.path.basename(l)
+
+        if os.path.isdir(os.path.join("./locale/", locale)):
+            tr = gettext.translation("messages",
+                                     localedir="locale",
+                                     languages=[locale])
+
+            env.install_gettext_translations(tr, newstyle=True)
+        else:
+            print("warning: locale {} not found".format(locale))
+        
+        ctx = dict(
+                lang=locale,
+                url=url,
+                self_localized=self_localized,
+                url_localized=url_localized,
+                filename=name + "." + ext)
+        ctx.update(default_ctx)
+
+        content = tmpl.render(**ctx)
+        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)

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



reply via email to

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