add custom localization support including german translation
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Sat, 7 Feb 2009 11:50:32 +0000 (11:50 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Sat, 7 Feb 2009 11:50:32 +0000 (11:50 +0000)
configure.ac
werbezapper/Makefile.am
werbezapper/po/Makefile.am [new file with mode: 0755]
werbezapper/po/WerbeZapper.pot [new file with mode: 0644]
werbezapper/po/de.po [new file with mode: 0644]
werbezapper/src/WerbeZapper.py
werbezapper/src/__init__.py
werbezapper/src/plugin.py

index a7231ea..19cb44a 100644 (file)
@@ -98,6 +98,7 @@ epgrefresh/src/Makefile
 epgrefresh/po/Makefile
 
 werbezapper/Makefile
+werbezapper/po/Makefile
 werbezapper/src/Makefile
 
 httpproxy/Makefile
index 308a09c..8078aa5 100755 (executable)
@@ -1 +1 @@
-SUBDIRS = src\r
+SUBDIRS = src po\r
diff --git a/werbezapper/po/Makefile.am b/werbezapper/po/Makefile.am
new file mode 100755 (executable)
index 0000000..3de18cb
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# to use this for the localisation of other plugins,
+# just change the DOMAIN to the name of the Plugin.
+# It is assumed, that the domain ist the same as
+# the directory name of the plugin.
+#
+
+DOMAIN=WerbeZapper
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/$(DOMAIN)
+#GETTEXT=./pygettext.py
+GETTEXT=xgettext
+
+#MSGFMT = ./msgfmt.py
+MSGFMT = msgfmt
+
+LANGS := de
+LANGPO := $(foreach LANG, $(LANGS),$(LANG).po)
+LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo)
+
+default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO)
+       for lang in $(LANGS); do \
+               mkdir -p $$lang/LC_MESSAGES; \
+               cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
+
+merge:
+       for lang in $(LANGS); do \
+               msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \
+       done
+
+
+# the TRANSLATORS: allows putting translation comments before the to-be-translated line.
+$(DOMAIN).pot:
+       $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../src/*.py
+       msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot
+       $(RM) $(DOMAIN).pot
+       mv $(DOMAIN)uniq.pot $(DOMAIN).pot
+
+.PHONY: $(DOMAIN).pot
+
+
+%.mo: %.po
+       $(MSGFMT) -o $@ $<
+
+%.po:
+       msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator
+
+CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo)
+
+clean-local:
+       $(RM) -r $(LANGS)
+
+install-data-am: default
+       for lang in $(LANGS); do \
+               mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \
+               cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
diff --git a/werbezapper/po/WerbeZapper.pot b/werbezapper/po/WerbeZapper.pot
new file mode 100644 (file)
index 0000000..7d426e1
--- /dev/null
@@ -0,0 +1,48 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-07 12:44+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"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/plugin.py:28
+msgid "Automatically zaps back to current service after given Time"
+msgstr ""
+
+#: ../src/WerbeZapper.py:55
+msgid "Custom"
+msgstr ""
+
+#: ../src/WerbeZapper.py:81
+msgid "How many minutes to wait until zapping back?"
+msgstr ""
+
+#: ../src/WerbeZapper.py:38
+msgid ""
+"Timer already running.\n"
+"Stop it?"
+msgstr ""
+
+#: ../src/WerbeZapper.py:47
+msgid "When to Zap back?"
+msgstr ""
+
+#: ../src/WerbeZapper.py:104
+#, python-format
+msgid "Zapping back in %d Minutes"
+msgstr ""
+
+#: ../src/WerbeZapper.py:50
+msgid "minutes"
+msgstr ""
diff --git a/werbezapper/po/de.po b/werbezapper/po/de.po
new file mode 100644 (file)
index 0000000..ffffdc1
--- /dev/null
@@ -0,0 +1,43 @@
+# German translations for enigma package.
+# Copyright (C) 2009 THE enigma'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the enigma package.
+# Automatically generated, 2009.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Enigma2 Plugin WerbeZapper\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-07 12:44+0100\n"
+"PO-Revision-Date: 2009-02-07 12:47+0100\n"
+"Last-Translator: Moritz Venn <moritz.venn@freaque.net>\n"
+"Language-Team: none\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"
+
+msgid "Automatically zaps back to current service after given Time"
+msgstr "Automatisch nach Zeitintervall auf einen Sender zurückschalten"
+
+msgid "Custom"
+msgstr "Angepasst"
+
+msgid "How many minutes to wait until zapping back?"
+msgstr "Wie viele Minuten vor Zurückschalten warten?"
+
+msgid ""
+"Timer already running.\n"
+"Stop it?"
+msgstr ""
+"WerbeZapper bereits aktiv.\n"
+"Jetzt anhalten?"
+
+msgid "When to Zap back?"
+msgstr "Wann zurückschalten?"
+
+#, python-format
+msgid "Zapping back in %d Minutes"
+msgstr "Schalte zurück in %d Minuten"
+
+msgid "minutes"
+msgstr "Minuten"
index 203d98a..0879fde 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 # GUI (Screens)
 from Screens.MessageBox import MessageBox
 
@@ -148,3 +151,4 @@ class WerbeZapper:
        def shutdown(self):
                self.zap_timer.callback.remove(self.zap)
                self.zap_timer = None
+
index e69de29..2e0fbf6 100644 (file)
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+from os import environ as os_environ
+import gettext
+
+def localeInit():
+       lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+       os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+       gettext.bindtextdomain("WerbeZapper", resolveFilename(SCOPE_PLUGINS, "Extensions/WerbeZapper/locale"))
+
+def _(txt):
+       t = gettext.dgettext("WerbeZapper", txt)
+       if t == txt:
+               print "[WerbeZapper] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
index c6a9eb0..49ac360 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 # Plugin
 from Plugins.Plugin import PluginDescriptor
 
@@ -21,9 +24,10 @@ def cleanup():
 def Plugins(**kwargs):
        return [
                PluginDescriptor(
-                       name="Werbezapper",
-                       description="Automatically zaps back to current service after given Time",
+                       name = "Werbezapper",
+                       description = _("Automatically zaps back to current service after given Time"),
                        where = PluginDescriptor.WHERE_EXTENSIONSMENU,
-                       fnc=main
+                       fnc = main
                )
        ]
+