]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Adding lib/webhooks/xlate.py, first translations
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 28 Dec 2018 09:17:41 +0000 (10:17 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 28 Dec 2018 09:17:41 +0000 (10:17 +0100)
lib/webhooks/base_app.py
lib/webhooks/xlate.py [new file with mode: 0644]
locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po
locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po
locale/puppetmaster_webhooks.pot

index 11108507321dd1384aaad003a8f6d31c5d86adb2..a18f948a576358789cfdbb8f4c43f221be05458d 100644 (file)
@@ -3,7 +3,7 @@
 """
 @author: Frank Brehm
 @contact: frank.brehm@pixelpark.com
-@copyright: © 2017 by Frank Brehm, Berlin
+@copyright: © 2018 by Frank Brehm, Berlin
 @summary: The module for the base application object.
 """
 from __future__ import absolute_import
diff --git a/lib/webhooks/xlate.py b/lib/webhooks/xlate.py
new file mode 100644 (file)
index 0000000..d0473c6
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2018 by Frank Brehm, Berlin
+@summary: The module for i18n.
+          It provides translation object, usable from all other
+          modules in this package.
+"""
+from __future__ import absolute_import, print_function
+
+# Standard modules
+import logging
+import gettext
+
+from pathlib import Path
+
+# Third party modules
+from babel.support import Translations
+
+DOMAIN = 'puppetmaster_webhooks'
+
+LOG = logging.getLogger(__name__)
+
+__version__ = '1.0.1'
+
+__me__ = Path(__file__).resolve()
+__module_dir__ = __me__.parent
+__lib_dir__ = __module_dir__.parent
+__base_dir__ = __lib_dir__.parent
+LOCALE_DIR = __base_dir__.joinpath('locale')
+if not LOCALE_DIR.is_dir():
+    LOCALE_DIR = __module_dir__.joinpath('locale')
+    if not LOCALE_DIR.is_dir():
+        LOCALE_DIR = None
+
+__mo_file__ = gettext.find(DOMAIN, str(LOCALE_DIR))
+if __mo_file__:
+    try:
+        with open(__mo_file__, 'rb') as F:
+            XLATOR = Translations(F, DOMAIN)
+    except FileNotFoundError:
+        XLATOR = gettext.NullTranslations()
+else:
+    XLATOR = gettext.NullTranslations()
+
+_ = XLATOR.gettext
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+    print(_("Module directory: {!r}").format(__module_dir__))
+    print(_("Base directory: {!r}").format(__base_dir__))
+    print(_("Locale directory: {!r}").format(LOCALE_DIR))
+    print(_("Locale domain: {!r}").format(DOMAIN))
+    print(_("Found .mo-file: {!r}").format(__mo_file__))
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
index 9ea966c1a57e88c333f57c65dff720fc11a56772..094a21cc695d86df8c6bec4bd437db61b115ed12 100644 (file)
@@ -7,9 +7,9 @@ msgid ""
 msgstr ""
 "Project-Id-Version: puppetmaster_webhooks 1.3.1\n"
 "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n"
-"POT-Creation-Date: 2018-12-28 09:57+0100\n"
-"PO-Revision-Date: 2018-12-28 09:57+0100\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"POT-Creation-Date: 2018-12-28 10:12+0100\n"
+"PO-Revision-Date: 2018-12-28 10:15+0100\n"
+"Last-Translator: Frank Brehm <frank.brehm@pixelpark.com>\n"
 "Language: de_DE\n"
 "Language-Team: de_DE <LL@li.org>\n"
 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
@@ -18,3 +18,23 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 2.6.0\n"
 
+#: lib/webhooks/xlate.py:54
+msgid "Module directory: {!r}"
+msgstr "Modul-Verzeichnis: {!r}"
+
+#: lib/webhooks/xlate.py:55
+msgid "Base directory: {!r}"
+msgstr "Basis-Verzeichnis: {!r}"
+
+#: lib/webhooks/xlate.py:56
+msgid "Locale directory: {!r}"
+msgstr "Verzeichnis für Locales: {!r}"
+
+#: lib/webhooks/xlate.py:57
+msgid "Locale domain: {!r}"
+msgstr "Locale-Domäne: {!r}"
+
+#: lib/webhooks/xlate.py:58
+msgid "Found .mo-file: {!r}"
+msgstr "Gefundene .mo-Datei: {!r}"
+
index 64679d04f3bc32b757368880bcbc33a06b4ad09b..3a181c56eb3d0fc62cdbcaf2e31d8a2f8bba9299 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: puppetmaster_webhooks 1.3.1\n"
 "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n"
-"POT-Creation-Date: 2018-12-28 09:57+0100\n"
+"POT-Creation-Date: 2018-12-28 10:12+0100\n"
 "PO-Revision-Date: 2018-12-28 09:57+0100\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language: en_US\n"
@@ -18,3 +18,23 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 2.6.0\n"
 
+#: lib/webhooks/xlate.py:54
+msgid "Module directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:55
+msgid "Base directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:56
+msgid "Locale directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:57
+msgid "Locale domain: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:58
+msgid "Found .mo-file: {!r}"
+msgstr ""
+
index 09e0f3d4f05a30918878d76e0160e4bc00ce4e05..08bc176ad02382aafd3c2f1d5817d00c51a85411 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: puppetmaster_webhooks 1.3.1\n"
 "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n"
-"POT-Creation-Date: 2018-12-28 09:57+0100\n"
+"POT-Creation-Date: 2018-12-28 10:12+0100\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"
@@ -17,3 +17,23 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 2.6.0\n"
 
+#: lib/webhooks/xlate.py:54
+msgid "Module directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:55
+msgid "Base directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:56
+msgid "Locale directory: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:57
+msgid "Locale domain: {!r}"
+msgstr ""
+
+#: lib/webhooks/xlate.py:58
+msgid "Found .mo-file: {!r}"
+msgstr ""
+