use gettext for translations, make some more strings translatable
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Tue, 17 Feb 2009 11:54:54 +0000 (11:54 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Tue, 17 Feb 2009 11:54:54 +0000 (11:54 +0000)
configure.ac
imdb/Makefile.am
imdb/po/Makefile.am [new file with mode: 0644]
imdb/po/de.po [new file with mode: 0644]
imdb/src/plugin.py
ofdb/Makefile.am
ofdb/po/Makefile.am [new file with mode: 0644]
ofdb/po/OFDb.pot [new file with mode: 0644]
ofdb/po/de.po [new file with mode: 0644]
ofdb/src/plugin.py

index 01171f1..0889af3 100644 (file)
@@ -109,9 +109,11 @@ startuptostandby/src/Makefile
 
 imdb/Makefile
 imdb/src/Makefile
+imdb/po/Makefile
 
 ofdb/Makefile
 ofdb/src/Makefile
+ofdb/po/Makefile
 
 networkwizard/Makefile
 networkwizard/src/Makefile
index af437a6..dd6709f 100755 (executable)
@@ -1 +1 @@
-SUBDIRS = src
+SUBDIRS = src po
diff --git a/imdb/po/Makefile.am b/imdb/po/Makefile.am
new file mode 100644 (file)
index 0000000..1ac3ba2
--- /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=IMDb
+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/imdb/po/de.po b/imdb/po/de.po
new file mode 100644 (file)
index 0000000..be40b4e
--- /dev/null
@@ -0,0 +1,98 @@
+# 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 IMDb Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-17 11:29+0100\n"
+"PO-Revision-Date: 2009-02-17 11:31+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 " as "
+msgstr " als "
+
+msgid "Ambiguous results"
+msgstr "Kein eindeutiger Treffer"
+
+msgid "Cast: "
+msgstr "Darsteller: "
+
+msgid "Channel Selection"
+msgstr "Kanalliste"
+
+msgid "Could't get Eventname"
+msgstr "Konnte Sendungstitel nicht feststellen"
+
+msgid "Details"
+msgstr ""
+
+#, python-format
+msgid "Downloading Movie Poster: %s..."
+msgstr "Lade Filmplakat herunter: %s..."
+
+msgid "Exit"
+msgstr "Beenden"
+
+msgid "Extra Info"
+msgstr "Zusatzinfos"
+
+msgid "IMDb Details parsed"
+msgstr "Filminformationen eingelesen"
+
+msgid "IMDb Download completed"
+msgstr "Download von IMDb abgeschlossen"
+
+msgid "IMDb Download failed"
+msgstr "Download von IMDb fehlgeschlagen"
+
+msgid "IMDb Plugin"
+msgstr ""
+
+msgid "IMDb Re-Download completed"
+msgstr "Erneuten Download ausgeführt"
+
+msgid "IMDb query failed!"
+msgstr "Anfrage an IMDb fehlgeschlagen!"
+
+msgid "Lookup"
+msgstr ""
+
+msgid "No IMDb match."
+msgstr "Keine passenden Einträge gefunden."
+
+msgid "No cast list found in the database."
+msgstr "Keine Darstellerliste in der Datenbank gefunden."
+
+msgid "No details found."
+msgstr "Keine Details gefunden."
+
+msgid "Please select the matching entry"
+msgstr "Bitte passenden Eintrag auswählen"
+
+#, python-format
+msgid "Query IMDb: %s..."
+msgstr "Frage bei IMDb an: %s..."
+
+msgid "Query details from the Internet Movie Database"
+msgstr "Filminformationen aus der Internet Movie Database"
+
+#, python-format
+msgid "Re-Query IMDb: %s..."
+msgstr "Frage erneut bei IMDb an: %s..."
+
+msgid "The Internet Movie Database"
+msgstr "Die Internet Movie Database"
+
+msgid "Title Menu"
+msgstr "Titelauswahl"
+
+msgid "no user rating yet"
+msgstr "noch keine Nutzerwertung"
index af7be40..28005c1 100755 (executable)
@@ -15,9 +15,26 @@ from Components.MenuList import MenuList
 from Components.Language import language
 from Components.ProgressBar import ProgressBar
 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from os import environ as os_environ
 import re
 import htmlentitydefs
 import urllib
+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("IMDb", resolveFilename(SCOPE_PLUGINS, "Extensions/IMDb/locale"))
+
+def _(txt):
+       t = gettext.dgettext("IMDb", txt)
+       if t == txt:
+               print "[IMDb] fallback to default translation for", txt 
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
 
 class IMDBChannelSelection(SimpleChannelSelection):
        def __init__(self, session):
@@ -115,7 +132,7 @@ class IMDB(Screen):
                self["starsbg"].hide()
                self.ratingstars = -1
 
-               self["titellabel"] = Label("The Internet Movie Database")
+               self["titellabel"] = Label(_("The Internet Movie Database"))
                self["detailslabel"] = ScrollLabel("")
                self["castlabel"] = ScrollLabel("")
                self["extralabel"] = ScrollLabel("")
@@ -125,7 +142,7 @@ class IMDB(Screen):
                self["menu"] = MenuList(self.resultlist)
                self["menu"].hide()
 
-               self["key_red"] = Button(self._("Exit"))
+               self["key_red"] = Button(_("Exit"))
                self["key_green"] = Button("")
                self["key_yellow"] = Button("")
                self["key_blue"] = Button("")
@@ -153,26 +170,11 @@ class IMDB(Screen):
 
        def dictionary_init(self):
                syslang = language.getLanguage()
-               if syslang.find("de") is -1:
+               if "de" not in syslang:
                        self.IMDBlanguage = ""  # set to empty ("") for english version
                else:
                        self.IMDBlanguage = "german." # it's a subdomain, so add a '.' at the end
 
-               self.dict = {}
-               self.dict["of"]="von"
-               self.dict[" as "]=" als "
-               self.dict["Ambiguous results"]="Kein eindeutiger Treffer"
-               self.dict["Please select the matching entry"]="Bitte passenden Eintrag auswählen"
-               self.dict["No IMDb match."]="Keine passenden Einträge gefunden."
-               self.dict["IMDb query failed!"]="IMDb-Query fehlgeschlagen!"
-               self.dict["No details found."]="Keine Details gefunden."
-               self.dict["no user rating yet"]="noch keine Nutzerwertung"
-               self.dict["Cast: "]="Darsteller: "
-               self.dict["No cast list found in the database."]="Keine Darstellerliste in der Datenbank gefunden."
-               self.dict["Exit"]="Beenden"
-               self.dict["Extra Info"]="Zusatzinfos"
-               self.dict["Title Menu"]="Titelauswahl"
-
                self.htmltags = re.compile('<.*?>')
 
                self.generalinfomask = re.compile(
@@ -207,12 +209,6 @@ class IMDB(Screen):
                '(?:.*?<h3>(?P<g_comments>Nutzerkommentare|User Comments)</h3>.*?<a href="/user/ur\d{7,7}/comments">(?P<commenter>.+?)\n</div>.*?<p>(?P<comment>.+?)</p>)*'
                , re.DOTALL)
 
-       def _(self, in_string):
-               out_string = in_string
-               if ((self.IMDBlanguage).find("german")) != -1:
-                       out_string = self.dict.get(in_string, in_string)
-               return out_string
-
        def resetLabels(self):
                self["detailslabel"].setText("")
                self["ratinglabel"].setText("")
@@ -249,12 +245,12 @@ class IMDB(Screen):
                        self["castlabel"].hide()
                        self["poster"].hide()
                        self["extralabel"].hide()
-                       self["titellabel"].setText(self._("Ambiguous results"))
-                       self["detailslabel"].setText(self._("Please select the matching entry"))
+                       self["titellabel"].setText(_("Ambiguous results"))
+                       self["detailslabel"].setText(_("Please select the matching entry"))
                        self["detailslabel"].show()
                        self["key_blue"].setText("")
-                       self["key_green"].setText(self._("Title Menu"))
-                       self["key_yellow"].setText(self._("Details"))
+                       self["key_green"].setText(_("Title Menu"))
+                       self["key_yellow"].setText(_("Details"))
                        self.Page = 0
 
        def showDetails(self):
@@ -265,7 +261,7 @@ class IMDB(Screen):
                if self.resultlist and self.Page == 0:
                        link = self["menu"].getCurrent()[1]
                        title = self["menu"].getCurrent()[0]
-                       self["statusbar"].setText("Re-Query IMDb: "+title+"...")
+                       self["statusbar"].setText(_("Re-Query IMDb: %s...") % (title))
                        localfile = "/tmp/imdbquery2.html"
                        fetchurl = "http://" + self.IMDBlanguage + "imdb.com/title/" + link
                        print "[IMDB] downloading query " + fetchurl + " to " + localfile
@@ -315,18 +311,18 @@ class IMDB(Screen):
                        if event:
                                self.eventName = event.getEventName()
                if self.eventName is not "":
-                       self["statusbar"].setText("Query IMDb: " + self.eventName + "...")
+                       self["statusbar"].setText(_("Query IMDb: %s...") % (self.eventName))
                        event_quoted = urllib.quote(self.eventName.decode('utf8').encode('latin-1','ignore'))
                        localfile = "/tmp/imdbquery.html"
                        fetchurl = "http://" + self.IMDBlanguage + "imdb.com/find?q=" + event_quoted + "&s=tt&site=aka"
                        print "[IMDB] Downloading Query " + fetchurl + " to " + localfile
                        downloadPage(fetchurl,localfile).addCallback(self.IMDBquery).addErrback(self.fetchFailed)
                else:
-                       self["statusbar"].setText("Could't get Eventname -_-")
+                       self["statusbar"].setText(_("Could't get Eventname"))
 
        def fetchFailed(self,string):
                print "[IMDB] fetch failed " + string
-               self["statusbar"].setText("IMDb Download failed -_-")
+               self["statusbar"].setText(_("IMDb Download failed"))
 
        def html2utf8(self,in_html):
                htmlentitynumbermask = re.compile('(&#(\d{1,5}?);)')
@@ -353,7 +349,7 @@ class IMDB(Screen):
 
        def IMDBquery(self,string):
                print "[IMDBquery]"
-               self["statusbar"].setText("IMDb Download completed")
+               self["statusbar"].setText(_("IMDb Download completed"))
 
                self.html2utf8(open("/tmp/imdbquery.html", "r").read())
 
@@ -374,23 +370,23 @@ class IMDB(Screen):
                                        self.Page = 1
                                        self.showMenu()
                                else:
-                                       self["detailslabel"].setText(self._("No IMDb match."))
-                                       self["statusbar"].setText("No IMDb match")
+                                       self["detailslabel"].setText(_("No IMDb match."))
+                                       self["statusbar"].setText(_("No IMDb match."))
                        else:
                                splitpos = self.eventName.find('(')
                                if splitpos > 0 and self.eventName.endswith(')'):
                                        self.eventName = self.eventName[splitpos+1:-1]
-                                       self["statusbar"].setText("Re-Query IMDb: " + self.eventName + "...")
+                                       self["statusbar"].setText(_("Re-Query IMDb: %s...") % (self.eventName))
                                        event_quoted = urllib.quote(self.eventName.decode('utf8').encode('latin-1','ignore'))
                                        localfile = "/tmp/imdbquery.html"
                                        fetchurl = "http://" + self.IMDBlanguage + "imdb.com/find?q=" + event_quoted + "&s=tt&site=aka"
                                        print "[IMDB] Downloading Query " + fetchurl + " to " + localfile
                                        downloadPage(fetchurl,localfile).addCallback(self.IMDBquery).addErrback(self.fetchFailed)
                                else:
-                                       self["detailslabel"].setText(self._("IMDb query failed!"))
+                                       self["detailslabel"].setText(_("IMDb query failed!"))
 
        def IMDBquery2(self,string):
-               self["statusbar"].setText("IMDb Re-Download completed")
+               self["statusbar"].setText(_("IMDb Re-Download completed"))
                self.html2utf8(open("/tmp/imdbquery2.html", "r").read())
                self.generalinfos = self.generalinfomask.search(self.inhtml)
                self.IMDBparse()
@@ -398,10 +394,10 @@ class IMDB(Screen):
        def IMDBparse(self):
                print "[IMDBparse]"
                self.Page = 1
-               Detailstext = self._("No details found.")
+               Detailstext = _("No details found.")
                if self.generalinfos:
-                       self["key_yellow"].setText(self._("Details"))
-                       self["statusbar"].setText("IMDb Details parsed ^^")
+                       self["key_yellow"].setText(_("Details"))
+                       self["statusbar"].setText(_("IMDb Details parsed"))
                        Titeltext = self.generalinfos.group("title")
                        if len(Titeltext) > 57:
                                Titeltext = Titeltext[0:54] + "..."
@@ -418,9 +414,8 @@ class IMDB(Screen):
                                        Detailstext += "Genre: "
                                        for x in genres:
                                                Detailstext += x.group(1) + " "
-                       detailscategories = ["director", "creator", "writer", "premiere", "seasons", "country"]
 
-                       for category in detailscategories:
+                       for category in ("director", "creator", "writer", "premiere", "seasons", "country"):
                                if self.generalinfos.group('g_'+category):
                                        Detailstext += "\n" + self.generalinfos.group('g_'+category) + ": " + self.generalinfos.group(category)
 
@@ -429,7 +424,7 @@ class IMDB(Screen):
 
                        ratingmask = re.compile('<h5>(?P<g_rating>Nutzer-Bewertung|User Rating):</h5>.*?<b>(?P<rating>.*?)/10</b>', re.DOTALL)
                        rating = ratingmask.search(self.inhtml)
-                       Ratingtext = self._("no user rating yet")
+                       Ratingtext = _("no user rating yet")
                        if rating:
                                Ratingtext = rating.group("g_rating") + ": " + rating.group("rating") + " / 10"
                                self.ratingstars = int(10*round(float(rating.group("rating").replace(',','.')),1))
@@ -444,17 +439,17 @@ class IMDB(Screen):
                                for x in castresult:
                                        Casttext += "\n" + self.htmltags.sub('', x.group(1))
                                        if x.group(2):
-                                               Casttext += self._(" als ") + self.htmltags.sub('', x.group(2).replace('/ ...',''))
+                                               Casttext += _(" as ") + self.htmltags.sub('', x.group(2).replace('/ ...',''))
                                if Casttext is not "":
-                                       Casttext = self._("Cast: ") + Casttext
+                                       Casttext = _("Cast: ") + Casttext
                                else:
-                                       Casttext = self._("No cast list found in the database.")
+                                       Casttext = _("No cast list found in the database.")
                                self["castlabel"].setText(Casttext)
                        postermask = re.compile('<div class="photo">.*?<img .*? src=\"(http.*?)\" .*?>', re.DOTALL)
                        posterurl = postermask.search(self.inhtml)
                        if posterurl and posterurl.group(1).find("jpg") > 0:
                                posterurl = posterurl.group(1)
-                               self["statusbar"].setText("Downloading Movie Poster: "+posterurl+"...")
+                               self["statusbar"].setText(_("Downloading Movie Poster: %s...") % (posterurl))
                                localfile = "/tmp/poster.jpg"
                                print "[IMDB] downloading poster " + posterurl + " to " + localfile
                                downloadPage(posterurl,localfile).addCallback(self.IMDBPoster).addErrback(self.fetchFailed)
@@ -464,9 +459,8 @@ class IMDB(Screen):
 
                        if extrainfos:
                                Extratext = "Extra Info\n"
-                               extracategories = ["tagline","outline","synopsis","keywords","awards","runtime","language","color","aspect","sound","cert","locations","company","trivia","goofs","quotes","connections"]
 
-                               for category in extracategories:
+                               for category in ("tagline","outline","synopsis","keywords","awards","runtime","language","color","aspect","sound","cert","locations","company","trivia","goofs","quotes","connections"):
                                        if extrainfos.group('g_'+category):
                                                Extratext += extrainfos.group('g_'+category) + ": " + self.htmltags.sub('',extrainfos.group(category).replace("\n",'').replace("<br>",'\n')) + "\n"
                                if extrainfos.group("g_comments"):
@@ -474,12 +468,12 @@ class IMDB(Screen):
 
                                self["extralabel"].setText(Extratext)
                                self["extralabel"].hide()
-                               self["key_blue"].setText(self._("Extra Info"))
+                               self["key_blue"].setText(_("Extra Info"))
 
                self["detailslabel"].setText(Detailstext)
 
        def IMDBPoster(self,string):
-               self["statusbar"].setText("IMDb Details parsed ^^")
+               self["statusbar"].setText(_("IMDb Details parsed"))
                if not string:
                        filename = "/tmp/poster.jpg"
                else:
@@ -508,7 +502,7 @@ class IMDbLCDScreen(Screen):
 
        def __init__(self, session, parent):
                Screen.__init__(self, session)
-               self["headline"] = Label("IMDB Plugin")
+               self["headline"] = Label(_("IMDb Plugin"))
 
 def eventinfo(session, servicelist, **kwargs):
        ref = session.nav.getCurrentlyPlayingServiceReference()
index af437a6..dd6709f 100755 (executable)
@@ -1 +1 @@
-SUBDIRS = src
+SUBDIRS = src po
diff --git a/ofdb/po/Makefile.am b/ofdb/po/Makefile.am
new file mode 100644 (file)
index 0000000..1ae0182
--- /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=OFDb
+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/ofdb/po/OFDb.pot b/ofdb/po/OFDb.pot
new file mode 100644 (file)
index 0000000..cb466eb
--- /dev/null
@@ -0,0 +1,116 @@
+# 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-17 11:43+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:239
+msgid "Ambiguous results"
+msgstr ""
+
+#: ../src/plugin.py:449
+msgid "Cast: "
+msgstr ""
+
+#: ../src/plugin.py:41
+msgid "Channel Selection"
+msgstr ""
+
+#: ../src/plugin.py:327
+msgid "Could't get Eventname"
+msgstr ""
+
+#: ../src/plugin.py:244 ../src/plugin.py:399
+msgid "Details"
+msgstr ""
+
+#: ../src/plugin.py:458
+#, python-format
+msgid "Downloading Movie Poster: %s..."
+msgstr ""
+
+#: ../src/plugin.py:140
+msgid "Exit"
+msgstr ""
+
+#: ../src/plugin.py:70
+msgid "Lookup"
+msgstr ""
+
+#: ../src/plugin.py:383 ../src/plugin.py:384
+msgid "No OFDb match."
+msgstr ""
+
+#: ../src/plugin.py:451
+msgid "No cast list found in the database."
+msgstr ""
+
+#: ../src/plugin.py:397
+msgid "No details found."
+msgstr ""
+
+#: ../src/plugin.py:400 ../src/plugin.py:469
+msgid "OFDb Details parsed"
+msgstr ""
+
+#: ../src/plugin.py:358
+msgid "OFDb Download completed"
+msgstr ""
+
+#: ../src/plugin.py:331
+msgid "OFDb Download failed"
+msgstr ""
+
+#: ../src/plugin.py:498
+msgid "OFDb Plugin"
+msgstr ""
+
+#: ../src/plugin.py:389
+msgid "OFDb Re-Download completed"
+msgstr ""
+
+#: ../src/plugin.py:386
+msgid "OFDb query failed!"
+msgstr ""
+
+#: ../src/plugin.py:240
+msgid "Please select the matching entry"
+msgstr ""
+
+#: ../src/plugin.py:317
+#, python-format
+msgid "Query OFDb: %s..."
+msgstr ""
+
+#: ../src/plugin.py:510 ../src/plugin.py:515 ../src/plugin.py:522
+msgid "Query details from the Online-Filmdatenbank"
+msgstr ""
+
+#: ../src/plugin.py:255
+#, python-format
+msgid "Re-Query OFDb: %s..."
+msgstr ""
+
+#: ../src/plugin.py:131
+msgid "The Online-Filmdatenbank"
+msgstr ""
+
+#: ../src/plugin.py:243
+msgid "Title Menu"
+msgstr ""
+
+#: ../src/plugin.py:430
+msgid "no user rating yet"
+msgstr ""
diff --git a/ofdb/po/de.po b/ofdb/po/de.po
new file mode 100644 (file)
index 0000000..12b3e2b
--- /dev/null
@@ -0,0 +1,92 @@
+# 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 OFDb Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-17 11:43+0100\n"
+"PO-Revision-Date: 2009-02-17 11: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 "Ambiguous results"
+msgstr "Kein eindeutiger Treffer"
+
+msgid "Cast: "
+msgstr "Darsteller: "
+
+msgid "Channel Selection"
+msgstr "Kanalliste"
+
+msgid "Could't get Eventname"
+msgstr "Konnte Sendungstitel nicht feststellen"
+
+msgid "Details"
+msgstr ""
+
+#, python-format
+msgid "Downloading Movie Poster: %s..."
+msgstr "Lade Filmplakat herunter: %s..."
+
+msgid "Exit"
+msgstr "Abbrechen"
+
+msgid "Lookup"
+msgstr ""
+
+msgid "No OFDb match."
+msgstr "Keine passenden Einträge gefunden."
+
+msgid "No cast list found in the database."
+msgstr "Keine Darstellerliste in der Datenbank gefunden."
+
+msgid "No details found."
+msgstr "Keine Details gefunden."
+
+msgid "OFDb Details parsed"
+msgstr "Filminformationen eingelesen"
+
+msgid "OFDb Download completed"
+msgstr "Download von OFDb abgeschlossen"
+
+msgid "OFDb Download failed"
+msgstr "Download von OFDb fehlgeschlagen"
+
+msgid "OFDb Plugin"
+msgstr ""
+
+msgid "OFDb Re-Download completed"
+msgstr "Erneuten Download ausgeführt"
+
+msgid "OFDb query failed!"
+msgstr "Anfrage an OFDb fehlgeschlagen!"
+
+msgid "Please select the matching entry"
+msgstr "Bitte passenden Eintrag auswählen"
+
+#, python-format
+msgid "Query OFDb: %s..."
+msgstr "Frage bei OFDb an: %s..."
+
+msgid "Query details from the Online-Filmdatenbank"
+msgstr "Filminformationen aus der Online-Filmdatenbank"
+
+#, python-format
+msgid "Re-Query OFDb: %s..."
+msgstr "Frage erneut bei OFDb an: %s..."
+
+msgid "The Online-Filmdatenbank"
+msgstr "Die Online-Filmdatenbank"
+
+msgid "Title Menu"
+msgstr "Titelauswahl"
+
+msgid "no user rating yet"
+msgstr "noch keine Nutzerwertung"
index 165971a..a9462a3 100644 (file)
@@ -15,9 +15,26 @@ from Components.MenuList import MenuList
 from Components.Language import language
 from Components.ProgressBar import ProgressBar
 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from os import environ as os_environ
 import re
 import htmlentitydefs
 import urllib
+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("IMDb", resolveFilename(SCOPE_PLUGINS, "Extensions/IMDb/locale"))
+
+def _(txt):
+    t = gettext.dgettext("IMDb", txt)
+    if t == txt:
+        print "[IMDb] fallback to default translation for", txt 
+        t = gettext.gettext(txt)
+    return t
+
+localeInit()
+language.addCallback(localeInit)
 
 class OFDBChannelSelection(SimpleChannelSelection):
        def __init__(self, session):
@@ -76,7 +93,7 @@ class OFDBEPGSelection(EPGSelection):
 
 class OFDB(Screen):
        skin = """
-               <screen name="OFDb" position="90,95" size="560,420" title="Internet Movie Database Details Plugin" >
+               <screen name="OFDb" position="90,95" size="560,420" title="Online-Filmdatenbank Details Plugin" >
                        <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
                        <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
                        <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
@@ -111,7 +128,7 @@ class OFDB(Screen):
                self["stars"].hide()
                self["starsbg"].hide()
                self.ratingstars = -1
-               self["titellabel"] = Label("The Internet Movie Database")
+               self["titellabel"] = Label(_("The Online-Filmdatenbank"))
                self["detailslabel"] = ScrollLabel("")
                self["castlabel"] = ScrollLabel("")
                self["extralabel"] = ScrollLabel("")
@@ -120,7 +137,7 @@ class OFDB(Screen):
                self.resultlist = []
                self["menu"] = MenuList(self.resultlist)
                self["menu"].hide()
-               self["key_red"] = Button(self._("Exit"))
+               self["key_red"] = Button(_("Exit"))
                self["key_green"] = Button("")
                self["key_yellow"] = Button("")
                self["key_blue"] = Button("")
@@ -147,26 +164,11 @@ class OFDB(Screen):
 
        def dictionary_init(self):
                syslang = language.getLanguage()
-               if syslang.find("de") is -1:
+               if "de" not in syslang:
                        self.OFDBlanguage = ""  # set to empty ("") for english version
                else:
                        self.OFDBlanguage = "german." # it's a subdomain, so add a '.' at the end
 
-               self.dict = {}
-               self.dict["of"]="von"
-               self.dict[" as "]=" als "
-               self.dict["Ambiguous results"]="Kein eindeutiger Treffer"
-               self.dict["Please select the matching entry"]="Bitte passenden Eintrag auswählen"
-               self.dict["No OFDb match."]="Keine passenden Einträge gefunden."
-               self.dict["OFDb query failed!"]="OFDb-Query fehlgeschlagen!"
-               self.dict["No details found."]="Keine Details gefunden."
-               self.dict["no user rating yet"]="noch keine Nutzerwertung"
-               self.dict["Cast: "]="Darsteller: "
-               self.dict["No cast list found in the database."]="Keine Darstellerliste in der Datenbank gefunden."
-               self.dict["Exit"]="Beenden"
-               self.dict["Extra Info"]="Zusatzinfos"
-               self.dict["Title Menu"]="Titelauswahl"
-
                self.htmltags = re.compile('<.*?>')
 
                self.generalinfomask = re.compile(
@@ -177,12 +179,6 @@ class OFDB(Screen):
                '(?:.*?(?P<g_director>Regie):[\s\S]*?class="Daten">(?P<director>.*?)(?:\.\.\.|</td>))*'
                , re.DOTALL)
 
-       def _(self, in_string):
-               out_string = in_string
-               if ((self.OFDBlanguage).find("german")) != -1:
-                       out_string = self.dict.get(in_string, in_string)
-               return out_string
-
        def resetLabels(self):
                self["detailslabel"].setText("")
                self["ratinglabel"].setText("")
@@ -219,12 +215,12 @@ class OFDB(Screen):
                        self["castlabel"].hide()
                        self["poster"].hide()
                        self["extralabel"].hide()
-                       self["titellabel"].setText(self._("Ambiguous results"))
-                       self["detailslabel"].setText(self._("Please select the matching entry"))
+                       self["titellabel"].setText(_("Ambiguous results"))
+                       self["detailslabel"].setText(_("Please select the matching entry"))
                        self["detailslabel"].show()
                        self["key_blue"].setText("")
-                       self["key_green"].setText(self._("Title Menu"))
-                       self["key_yellow"].setText(self._("Details"))
+                       self["key_green"].setText(_("Title Menu"))
+                       self["key_yellow"].setText(_("Details"))
                        self.Page = 0
 
        def showDetails(self):
@@ -235,7 +231,7 @@ class OFDB(Screen):
                if self.resultlist and self.Page == 0:
                        link = self["menu"].getCurrent()[1]
                        title = self["menu"].getCurrent()[0]
-                       self["statusbar"].setText("Re-Query OFDb: "+title+"...")
+                       self["statusbar"].setText(_("Re-Query OFDb: %s...") % (title))
                        localfile = "/tmp/ofdbquery2.html"
                        fetchurl = "http://www.ofdb.de/film/" + link
                        print "[OFDb] downloading query " + fetchurl + " to " + localfile
@@ -297,7 +293,7 @@ class OFDB(Screen):
                                if self.eventName[:4].capitalize() == article + " ":
                                        self.eventName = self.eventName[4:] + ", " + article
                        
-                       self["statusbar"].setText("Query OFDb: " + self.eventName + "...")
+                       self["statusbar"].setText(_("Query OFDb: %s...") % (self.eventName))
                        try:
                                self.eventName = urllib.quote(self.eventName)
                        except:
@@ -307,11 +303,11 @@ class OFDB(Screen):
                        print "[OFDb] Downloading Query " + fetchurl + " to " + localfile
                        downloadPage(fetchurl,localfile).addCallback(self.OFDBquery).addErrback(self.fetchFailed)
                else:
-                       self["statusbar"].setText("Could't get Eventname -_-")
+                       self["statusbar"].setText(_("Could't get Eventname"))
 
        def fetchFailed(self,string):
                print "[OFDb] fetch failed " + string
-               self["statusbar"].setText("OFDb Download failed -_-")
+               self["statusbar"].setText(_("OFDb Download failed"))
 
        def html2utf8(self,in_html):
                htmlentitynumbermask = re.compile('(&#(\d{1,5}?);)')
@@ -338,7 +334,7 @@ class OFDB(Screen):
 
        def OFDBquery(self,string):
                print "[OFDBquery]"
-               self["statusbar"].setText("OFDb Download completed")
+               self["statusbar"].setText(_("OFDb Download completed"))
 
                self.html2utf8(open("/tmp/ofdbquery.html", "r").read())
 
@@ -363,13 +359,13 @@ class OFDB(Screen):
                                        self.Page = 1
                                        self.showMenu()
                                else:
-                                       self["detailslabel"].setText(self._("No OFDb match."))
-                                       self["statusbar"].setText("No OFDb match")
+                                       self["detailslabel"].setText(_("No OFDb match."))
+                                       self["statusbar"].setText(_("No OFDb match."))
                        else:
-                               self["detailslabel"].setText(self._("OFDb query failed!"))
+                               self["detailslabel"].setText(_("OFDb query failed!"))
 
        def OFDBquery2(self,string):
-               self["statusbar"].setText("OFDb Re-Download completed")
+               self["statusbar"].setText(_("OFDb Re-Download completed"))
                self.html2utf8(open("/tmp/ofdbquery2.html", "r").read())
                self.generalinfos = self.generalinfomask.search(self.inhtml)
                self.OFDBparse()
@@ -377,10 +373,10 @@ class OFDB(Screen):
        def OFDBparse(self):
                print "[OFDBparse]"
                self.Page = 1
-               Detailstext = self._("No details found.")
+               Detailstext = _("No details found.")
                if self.generalinfos:
-                       self["key_yellow"].setText(self._("Details"))
-                       self["statusbar"].setText("OFDb Details parsed ^^")
+                       self["key_yellow"].setText(_("Details"))
+                       self["statusbar"].setText(_("OFDb Details parsed"))
                        
                        Titeltext = self.generalinfos.group("title")
                        if len(Titeltext) > 57:
@@ -399,9 +395,7 @@ class OFDB(Screen):
                                        for x in genres:
                                                Detailstext += self.htmltags.sub('', x.group(1)) + " "
 
-                       detailscategories = ["director", "year", "country", "original"]
-
-                       for category in detailscategories:
+                       for category in ("director", "year", "country", "original"):
                                if self.generalinfos.group('g_'+category):
                                        Detailstext += "\n" + self.generalinfos.group('g_'+category) + ": " + self.htmltags.sub('', self.generalinfos.group(category).replace("<br>",' '))
 
@@ -412,7 +406,7 @@ class OFDB(Screen):
 
                        ratingmask = re.compile('<td>[\s\S]*notenskala.*(?P<g_rating>Note: )(?P<rating>\d.\d{2,2})[\s\S]*</td>', re.DOTALL)
                        rating = ratingmask.search(self.inhtml)
-                       Ratingtext = self._("no user rating yet")
+                       Ratingtext = _("no user rating yet")
                        if rating:
                                Ratingtext = rating.group("g_rating") + rating.group("rating") + " / 10"
                                self.ratingstars = int(10*round(float(rating.group("rating")),1))
@@ -431,28 +425,28 @@ class OFDB(Screen):
                                        for x in cast:
                                                Casttext += "\n" + self.htmltags.sub('', x.group(1))
                                        if Casttext is not "":
-                                               Casttext = self._("Cast: ") + Casttext
+                                               Casttext = _("Cast: ") + Casttext
                                        else:
-                                               Casttext = self._("No cast list found in the database.")
+                                               Casttext = _("No cast list found in the database.")
                                        self["castlabel"].setText(Casttext)
 
                        postermask = re.compile('<img src=\"(http://img.ofdb.de/film.*?)\" alt', re.DOTALL)
                        posterurl = postermask.search(self.inhtml)
                        if posterurl and posterurl.group(1).find("jpg") > 0:
                                posterurl = posterurl.group(1)
-                               self["statusbar"].setText("Downloading Movie Poster: "+posterurl+"...")
+                               self["statusbar"].setText(_("Downloading Movie Poster: %s...") % (posterurl))
                                localfile = "/tmp/poster.jpg"
                                print "[OFDb] downloading poster " + posterurl + " to " + localfile
                                downloadPage(posterurl,localfile).addCallback(self.OFDBPoster).addErrback(self.fetchFailed)
                        else:
                                print "no jpg poster!"
-                               self.OFDBPoster("kein Poster")
+                               self.OFDBPoster(noPoster = True)
 
                self["detailslabel"].setText(Detailstext)
                
-       def OFDBPoster(self,string):
-               self["statusbar"].setText("OFDb Details parsed ^^")
-               if not string:
+       def OFDBPoster(self, noPoster = False):
+               self["statusbar"].setText(_("OFDb Details parsed"))
+               if not noPoster:
                        filename = "/tmp/poster.jpg"
                else:
                        filename = resolveFilename(SCOPE_PLUGINS, "Extensions/OFDb/no_poster.png")
@@ -480,7 +474,7 @@ class OFDbLCDScreen(Screen):
 
        def __init__(self, session, parent):
                Screen.__init__(self, session)
-               self["headline"] = Label("OFDb Plugin")
+               self["headline"] = Label(_("OFDb Plugin"))
 
 def eventinfo(session, servicelist, **kwargs):
        ref = session.nav.getCurrentlyPlayingServiceReference()