From: Frank Brehm Date: Fri, 28 Dec 2018 09:17:41 +0000 (+0100) Subject: Adding lib/webhooks/xlate.py, first translations X-Git-Tag: 1.6.4^2~97 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=595413fa3bd403993ec7dbf484a3d1b84c021f58;p=pixelpark%2Fpuppetmaster-webhooks.git Adding lib/webhooks/xlate.py, first translations --- diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 1110850..a18f948 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -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 index 0000000..d0473c6 --- /dev/null +++ b/lib/webhooks/xlate.py @@ -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 diff --git a/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po b/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po index 9ea966c..094a21c 100644 --- a/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po +++ b/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po @@ -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 \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 \n" "Language: de_DE\n" "Language-Team: de_DE \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}" + diff --git a/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po b/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po index 64679d0..3a181c5 100644 --- a/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po +++ b/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po @@ -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 \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 "" + diff --git a/locale/puppetmaster_webhooks.pot b/locale/puppetmaster_webhooks.pot index 09e0f3d..08bc176 100644 --- a/locale/puppetmaster_webhooks.pot +++ b/locale/puppetmaster_webhooks.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" +