add custom localization support including german translation
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Fri, 6 Feb 2009 16:22:02 +0000 (16:22 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Fri, 6 Feb 2009 16:22:02 +0000 (16:22 +0000)
configure.ac
epgsearch/Makefile.am
epgsearch/po/EPGSearch.pot [new file with mode: 0644]
epgsearch/po/Makefile.am [new file with mode: 0644]
epgsearch/po/de.po [new file with mode: 0644]
epgsearch/src/EPGSearch.py
epgsearch/src/__init__.py
epgsearch/src/plugin.py

index 50469a1..9e309bb 100644 (file)
@@ -166,5 +166,6 @@ mediadownloader/Makefile
 mediadownloader/src/Makefile
 
 epgsearch/Makefile
+epgsearch/po/Makefile
 epgsearch/src/Makefile
 ])
index 308a09c..8078aa5 100755 (executable)
@@ -1 +1 @@
-SUBDIRS = src\r
+SUBDIRS = src po\r
diff --git a/epgsearch/po/EPGSearch.pot b/epgsearch/po/EPGSearch.pot
new file mode 100644 (file)
index 0000000..dbbfca6
--- /dev/null
@@ -0,0 +1,65 @@
+# 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-06 17:13+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/EPGSearch.py:137
+msgid "Cancel"
+msgstr ""
+
+#: ../src/EPGSearch.py:175
+msgid "Channel Selection"
+msgstr ""
+
+#: ../src/EPGSearch.py:52
+msgid "Enter text to search for"
+msgstr ""
+
+#: ../src/EPGSearch.py:29
+msgid "History"
+msgstr ""
+
+#: ../src/EPGSearch.py:58
+msgid "Import from EPG"
+msgstr ""
+
+#: ../src/EPGSearch.py:57
+msgid "Import from Timer"
+msgstr ""
+
+#: ../src/EPGSearch.py:28
+msgid "New Search"
+msgstr ""
+
+#: ../src/EPGSearch.py:138
+msgid "OK"
+msgstr ""
+
+#: ../src/EPGSearch.py:202
+msgid "Search"
+msgstr ""
+
+#: ../src/plugin.py:45 ../src/plugin.py:50 ../src/plugin.py:56
+msgid "Search EPG"
+msgstr ""
+
+#: ../src/EPGSearch.py:152
+msgid "Select a timer to search"
+msgstr ""
+
+#: ../src/EPGSearch.py:87
+msgid "Select text to search for"
+msgstr ""
diff --git a/epgsearch/po/Makefile.am b/epgsearch/po/Makefile.am
new file mode 100644 (file)
index 0000000..f110268
--- /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=EPGSearch
+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/epgsearch/po/de.po b/epgsearch/po/de.po
new file mode 100644 (file)
index 0000000..0711b27
--- /dev/null
@@ -0,0 +1,53 @@
+# 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: Enigma 2 EPGSearch Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-06 17:13+0100\n"
+"PO-Revision-Date: 2009-02-06 17:20+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 "Cancel"
+msgstr "Abbrechen"
+
+msgid "Channel Selection"
+msgstr "Kanalliste"
+
+msgid "Enter text to search for"
+msgstr "Gib den zu suchenden Text ein"
+
+msgid "History"
+msgstr "Verlauf"
+
+msgid "Import from EPG"
+msgstr "Importiere aus EPG"
+
+msgid "Import from Timer"
+msgstr "Importiere aus Timer"
+
+msgid "New Search"
+msgstr "Neue Suche"
+
+msgid "OK"
+msgstr "OK"
+
+msgid "Search"
+msgstr "Suche"
+
+msgid "Search EPG"
+msgstr "Durchsuche EPG"
+
+msgid "Select a timer to search"
+msgstr "Wähle einen Timer aus"
+
+msgid "Select text to search for"
+msgstr "Wähle den zu suchenden Text aus"
index 1fc09f4..26173b3 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 from enigma import eEPGCache, eServiceReference
 
 from Screens.ChannelSelection import SimpleChannelSelection
index e69de29..2107762 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("EPGSearch", resolveFilename(SCOPE_PLUGINS, "Extensions/EPGSearch/locale"))
+
+def _(txt):
+       t = gettext.dgettext("EPGSearch", txt)
+       if t == txt:
+               print "[EPGSearch] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
index fcc52ff..748830f 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 from enigma import eServiceCenter
 
 # Config