add support for custom localizations and german translation
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 16 Feb 2009 22:11:32 +0000 (22:11 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 16 Feb 2009 22:11:32 +0000 (22:11 +0000)
configure.ac
tageditor/Makefile.am
tageditor/po/Makefile.am [new file with mode: 0644]
tageditor/po/TagEditor.pot [new file with mode: 0644]
tageditor/po/de.po [new file with mode: 0644]
tageditor/src/__init__.py
tageditor/src/plugin.py

index d12235f..01171f1 100644 (file)
@@ -127,6 +127,7 @@ moviecut/src_py/Makefile
 
 tageditor/Makefile
 tageditor/src/Makefile
+tageditor/po/Makefile
 
 cdinfo/Makefile
 cdinfo/src/Makefile
index af437a6..dd6709f 100644 (file)
@@ -1 +1 @@
-SUBDIRS = src
+SUBDIRS = src po
diff --git a/tageditor/po/Makefile.am b/tageditor/po/Makefile.am
new file mode 100644 (file)
index 0000000..d21c277
--- /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=TagEditor
+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/tageditor/po/TagEditor.pot b/tageditor/po/TagEditor.pot
new file mode 100644 (file)
index 0000000..9de0dcf
--- /dev/null
@@ -0,0 +1,81 @@
+# 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-16 23:05+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:251
+msgid "Add new tag..."
+msgstr ""
+
+#: ../src/plugin.py:45
+msgid "Cancel"
+msgstr ""
+
+#: ../src/plugin.py:255
+msgid "Delete all tags..."
+msgstr ""
+
+#: ../src/plugin.py:253
+msgid "Delete this tag..."
+msgstr ""
+
+#: ../src/plugin.py:254
+msgid "Delete unused tags"
+msgstr ""
+
+#: ../src/plugin.py:237
+msgid ""
+"Do you really want to delete all tags everywhere?\n"
+"(Note that 'Cancel' will not undo this!)"
+msgstr ""
+
+#: ../src/plugin.py:220
+#, python-format
+msgid ""
+"Do you really want to delete tag \"%s\" everywhere?\n"
+"(Note that 'Cancel' will not undo this!)"
+msgstr ""
+
+#: ../src/plugin.py:25
+msgid "Edit tags..."
+msgstr ""
+
+#: ../src/plugin.py:48
+msgid "Load"
+msgstr ""
+
+#: ../src/plugin.py:47
+msgid "New"
+msgstr ""
+
+#: ../src/plugin.py:46
+msgid "OK"
+msgstr ""
+
+#: ../src/plugin.py:77
+msgid "Please enter the new tag"
+msgstr ""
+
+#: ../src/plugin.py:252
+msgid "Rename this tag..."
+msgstr ""
+
+#: ../src/plugin.py:200
+#, python-format
+msgid ""
+"Replace tag \"%s\" everywhere with:   (Note that 'Cancel' will not undo "
+"this!)"
+msgstr ""
diff --git a/tageditor/po/de.po b/tageditor/po/de.po
new file mode 100644 (file)
index 0000000..651c778
--- /dev/null
@@ -0,0 +1,73 @@
+# 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 TagEditor Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-16 23:05+0100\n"
+"PO-Revision-Date: 2009-02-16 23:06+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 "Add new tag..."
+msgstr "Neuen Tag hinzufügen..."
+
+msgid "Cancel"
+msgstr "Abbrechen"
+
+msgid "Delete all tags..."
+msgstr "Alle Tags entfernen..."
+
+msgid "Delete this tag..."
+msgstr "Ausgewählten Tag entfernen..."
+
+msgid "Delete unused tags"
+msgstr "Ungenutzte Tags entfernen"
+
+msgid ""
+"Do you really want to delete all tags everywhere?\n"
+"(Note that 'Cancel' will not undo this!)"
+msgstr ""
+"Wirklich ALLE gesetzten Tags entfernen?\n"
+"('Abbrechen' kann dies nicht rückgängig machen!)"
+
+#, python-format
+msgid ""
+"Do you really want to delete tag \"%s\" everywhere?\n"
+"(Note that 'Cancel' will not undo this!)"
+msgstr ""
+"Wirklich den Tag \"%s\" überall entfernen?\n"
+"('Abbrechen' kann dies nicht rückgängig machen!)"
+
+msgid "Edit tags..."
+msgstr "Tags bearbeiten..."
+
+msgid "Load"
+msgstr "Laden"
+
+msgid "New"
+msgstr "Neu"
+
+msgid "OK"
+msgstr "OK"
+
+msgid "Please enter the new tag"
+msgstr "Bitte gib den neuen Tag an"
+
+msgid "Rename this tag..."
+msgstr "Ausgewählten Tag umbenennen..."
+
+#, python-format
+msgid ""
+"Replace tag \"%s\" everywhere with:   (Note that 'Cancel' will not undo "
+"this!)"
+msgstr ""
+"Den Tag \"%s\" überall ersetzen durch:   ('Abbrechen' kann dies nicht "
+"rückgängig machen!)"
index e69de29..b67682e 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("TagEditor", resolveFilename(SCOPE_PLUGINS, "Extensions/TagEditor/locale"))
+
+def _(txt):
+       t = gettext.dgettext("TagEditor", txt)
+       if t == txt:
+               print "[TagEditor] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
index 1adf711..5cdea0f 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 from Plugins.Plugin import PluginDescriptor
 from Screens.Screen import Screen
 from Screens.InputBox import InputBox
@@ -245,11 +248,11 @@ class TagEditor(Screen):
 
        def showMenu(self):
                menu = [
-                       (_("Add new tag"), self.addCustom),
-                       (_("Rename this tag"), self.renameTag),
-                       (_("Delete this tag"), self.removeTag),
+                       (_("Add new tag..."), self.addCustom),
+                       (_("Rename this tag..."), self.renameTag),
+                       (_("Delete this tag..."), self.removeTag),
                        (_("Delete unused tags"), self.removeUnused),
-                       (_("Delete all tags"), self.removeAll)
+                       (_("Delete all tags..."), self.removeAll)
                ]
                self.session.openWithCallback(self.menuCallback, ChoiceBox, title = "", list = menu)