From 12ab167758db01aef30a2d26b42dbda1a4d2a5d4 Mon Sep 17 00:00:00 2001 From: Moritz Venn Date: Mon, 16 Feb 2009 22:11:32 +0000 Subject: [PATCH] add support for custom localizations and german translation --- configure.ac | 1 + tageditor/Makefile.am | 2 +- tageditor/po/Makefile.am | 57 ++++++++++++++++++++++++++++++++ tageditor/po/TagEditor.pot | 81 ++++++++++++++++++++++++++++++++++++++++++++++ tageditor/po/de.po | 73 +++++++++++++++++++++++++++++++++++++++++ tageditor/src/__init__.py | 21 ++++++++++++ tageditor/src/plugin.py | 11 ++++--- 7 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 tageditor/po/Makefile.am create mode 100644 tageditor/po/TagEditor.pot create mode 100644 tageditor/po/de.po diff --git a/configure.ac b/configure.ac index d12235f..01171f1 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,7 @@ moviecut/src_py/Makefile tageditor/Makefile tageditor/src/Makefile +tageditor/po/Makefile cdinfo/Makefile cdinfo/src/Makefile diff --git a/tageditor/Makefile.am b/tageditor/Makefile.am index af437a6..dd6709f 100644 --- a/tageditor/Makefile.am +++ b/tageditor/Makefile.am @@ -1 +1 @@ -SUBDIRS = src +SUBDIRS = src po diff --git a/tageditor/po/Makefile.am b/tageditor/po/Makefile.am new file mode 100644 index 0000000..d21c277 --- /dev/null +++ b/tageditor/po/Makefile.am @@ -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 index 0000000..9de0dcf --- /dev/null +++ b/tageditor/po/TagEditor.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 index 0000000..651c778 --- /dev/null +++ b/tageditor/po/de.po @@ -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 \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!)" diff --git a/tageditor/src/__init__.py b/tageditor/src/__init__.py index e69de29..b67682e 100644 --- a/tageditor/src/__init__.py +++ b/tageditor/src/__init__.py @@ -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) + diff --git a/tageditor/src/plugin.py b/tageditor/src/plugin.py index 1adf711..5cdea0f 100644 --- a/tageditor/src/plugin.py +++ b/tageditor/src/plugin.py @@ -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) -- 2.7.4