From 79abe74f210da34280391420ac1b6ed4e95abc8d Mon Sep 17 00:00:00 2001 From: "Dr.Best" Date: Tue, 18 May 2010 20:25:40 +0000 Subject: [PATCH] - add support for custom localizations and german translation - changed caption width for long city names Thanks to mcfreis for this patch! :-) --- configure.ac | 1 + weatherplugin/Makefile.am | 2 +- weatherplugin/po/Makefile.am | 57 ++++++++++++++++++++++++ weatherplugin/po/WeatherPlugin.pot | 80 ++++++++++++++++++++++++++++++++++ weatherplugin/po/de.po | 88 ++++++++++++++++++++++++++++++++++++++ weatherplugin/src/__init__.py | 19 ++++++++ weatherplugin/src/plugin.py | 42 ++++++++++-------- weatherplugin/src/setup.py | 7 ++- 8 files changed, 274 insertions(+), 22 deletions(-) create mode 100644 weatherplugin/po/Makefile.am create mode 100644 weatherplugin/po/WeatherPlugin.pot create mode 100644 weatherplugin/po/de.po diff --git a/configure.ac b/configure.ac index fe6fc73..4ddb1b1 100644 --- a/configure.ac +++ b/configure.ac @@ -344,6 +344,7 @@ vxdcontrol/src/data/Makefile weatherplugin/Makefile weatherplugin/meta/Makefile +weatherplugin/po/Makefile weatherplugin/src/Makefile webcamviewer/Makefile diff --git a/weatherplugin/Makefile.am b/weatherplugin/Makefile.am index ff1ac3d..2966ae1 100755 --- a/weatherplugin/Makefile.am +++ b/weatherplugin/Makefile.am @@ -1 +1 @@ -SUBDIRS = src meta +SUBDIRS = po src meta diff --git a/weatherplugin/po/Makefile.am b/weatherplugin/po/Makefile.am new file mode 100644 index 0000000..9013003 --- /dev/null +++ b/weatherplugin/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=WeatherPlugin +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/weatherplugin/po/WeatherPlugin.pot b/weatherplugin/po/WeatherPlugin.pot new file mode 100644 index 0000000..bdb9e57 --- /dev/null +++ b/weatherplugin/po/WeatherPlugin.pot @@ -0,0 +1,80 @@ +# 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: 2010-05-15 23:35+0200\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/setup.py:66 +msgid "Add" +msgstr "" + +#: ../src/setup.py:171 +msgid "Cancel" +msgstr "" + +#: ../src/setup.py:64 +msgid "City" +msgstr "" + +#: ../src/setup.py:183 +msgid "City or Postal Code" +msgstr "" + +#: ../src/plugin.py:203 +#, python-format +msgid "Current: %s" +msgstr "" + +#: ../src/setup.py:68 ../src/setup.py:173 +msgid "Delete" +msgstr "" + +#: ../src/setup.py:67 +msgid "Edit" +msgstr "" + +#: ../src/plugin.py:130 +msgid "Getting weather information..." +msgstr "" + +#: ../src/setup.py:65 ../src/setup.py:184 +msgid "Language" +msgstr "" + +#: ../src/plugin.py:134 +msgid "" +"No locations defined...\n" +"Press 'Menu' to do that." +msgstr "" + +#: ../src/setup.py:172 +msgid "OK" +msgstr "" + +#: ../src/setup.py:106 ../src/setup.py:207 +msgid "Really delete this WeatherPlugin Entry?" +msgstr "" + +#: ../src/plugin.py:61 +msgid "Weather Plugin" +msgstr "" + +#: ../src/setup.py:161 +msgid "WeatherPlugin: Edit Entry" +msgstr "" + +#: ../src/setup.py:59 +msgid "WeatherPlugin: List of Entries" +msgstr "" diff --git a/weatherplugin/po/de.po b/weatherplugin/po/de.po new file mode 100644 index 0000000..f8f8db5 --- /dev/null +++ b/weatherplugin/po/de.po @@ -0,0 +1,88 @@ +# 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. +# +msgid "" +msgstr "" +"Project-Id-Version: WeatherPlugin\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-05-15 11:38+0200\n" +"PO-Revision-Date: 2010-05-15 16:42+0100\n" +"Last-Translator: Björn Freise \n" +"Language-Team: Björn Freise \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: German\n" +"X-Poedit-Country: GERMANY\n" +"X-Poedit-SourceCharset: utf-8\n" + +#: ../src/setup.py:66 +msgid "Add" +msgstr "Hinzufügen" + +#: ../src/setup.py:171 +msgid "Cancel" +msgstr "Abbrechen" + +#: ../src/setup.py:64 +msgid "City" +msgstr "Ort" + +#: ../src/setup.py:183 +msgid "City or Postal Code" +msgstr "Ort oder Postleitzahl" + +#: ../src/plugin.py:203 +#, python-format +msgid "Current: %s" +msgstr "Aktuell: %s" + +#: ../src/setup.py:68 +#: ../src/setup.py:173 +msgid "Delete" +msgstr "Löschen" + +#: ../src/setup.py:67 +msgid "Edit" +msgstr "Bearbeiten" + +#: ../src/plugin.py:130 +msgid "Getting weather information..." +msgstr "Laden der Wetterinformationen..." + +#: ../src/setup.py:65 +#: ../src/setup.py:184 +msgid "Language" +msgstr "Sprache" + +#: ../src/plugin.py:134 +msgid "" +"No locations defined...\n" +"Press 'Menu' to do that." +msgstr "" +"Keine Einträge vorhanden.\n" +"Bitte 'Menu' drücken um einen Eintrag anzulegen." + +#: ../src/setup.py:172 +msgid "OK" +msgstr "OK" + +#: ../src/setup.py:106 +#: ../src/setup.py:207 +msgid "Really delete this WeatherPlugin Entry?" +msgstr "Soll der Eintrag wirklich gelöscht werden?" + +#: ../src/plugin.py:61 +msgid "Weather Plugin" +msgstr "Wetterinformationen" + +#: ../src/setup.py:161 +msgid "WeatherPlugin: Edit Entry" +msgstr "Wetterinformationen: Eintrag bearbeiten" + +#: ../src/setup.py:59 +msgid "WeatherPlugin: List of Entries" +msgstr "Wetterinformationen: Liste der Einträge" + diff --git a/weatherplugin/src/__init__.py b/weatherplugin/src/__init__.py index e69de29..3c408a3 100644 --- a/weatherplugin/src/__init__.py +++ b/weatherplugin/src/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from Components.Language import language +from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE +import os,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("WeatherPlugin", resolveFilename(SCOPE_PLUGINS, "Extensions/WeatherPlugin/locale")) + +def _(txt): + t = gettext.dgettext("WeatherPlugin", txt) + if t == txt: + print "[WeatherPlugin] fallback to default translation for", txt + t = gettext.gettext(txt) + return t + +localeInit() +language.addCallback(localeInit) diff --git a/weatherplugin/src/plugin.py b/weatherplugin/src/plugin.py index ec17f26..6b78422 100644 --- a/weatherplugin/src/plugin.py +++ b/weatherplugin/src/plugin.py @@ -18,6 +18,9 @@ # GNU General Public License for more details. # +# for localized messages +from . import _ + from Plugins.Plugin import PluginDescriptor from Screens.Screen import Screen from Components.ActionMap import ActionMap @@ -58,36 +61,37 @@ def main(session,**kwargs): session.open(WeatherPlugin) def Plugins(**kwargs): - list = [PluginDescriptor(name="Weather Plugin", description=_("Weather Plugin"), where = [PluginDescriptor.WHERE_EXTENSIONSMENU], fnc=main)] + list = [PluginDescriptor(name=_("Weather Plugin"), description=_("Weather Plugin"), where = [PluginDescriptor.WHERE_EXTENSIONSMENU], fnc=main)] return list class WeatherPlugin(Screen): skin = """ - + - - - - - - - - - - - - - - - - - """ + + + + + + + + + + + + + + + + + """ % _("Weather Plugin") def __init__(self, session): Screen.__init__(self, session) + self["actions"] = ActionMap(["WizardActions", "DirectionActions", "ColorActions", "EPGSelectActions"], { "back": self.close, diff --git a/weatherplugin/src/setup.py b/weatherplugin/src/setup.py index 65f6006..faf6239 100644 --- a/weatherplugin/src/setup.py +++ b/weatherplugin/src/setup.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # # Weather Plugin E2 # @@ -17,6 +18,9 @@ # GNU General Public License for more details. # +# for localized messages +from . import _ + from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, \ RT_VALIGN_CENTER from Screens.Screen import Screen @@ -154,11 +158,10 @@ class WeatherPluginEntryConfigScreen(ConfigListScreen, Screen): - """ + """ % _("WeatherPlugin: Edit Entry") def __init__(self, session, entry): Screen.__init__(self, session) - self.title = _("WeatherPlugin: Edit Entry") self["actions"] = ActionMap(["SetupActions", "ColorActions"], { -- 2.7.4