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

index 19cb44a..d12235f 100644 (file)
@@ -119,6 +119,7 @@ networkwizard/po/Makefile
 
 movieretitle/Makefile
 movieretitle/src/Makefile
+movieretitle/po/Makefile
 
 moviecut/Makefile
 moviecut/src_cc/Makefile
index ef67721..fee99d0 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS = src
+SUBDIRS = src po
 
 EXTRA_DIST = Readme-MovieRetitle-1.2.txt
diff --git a/movieretitle/po/Makefile.am b/movieretitle/po/Makefile.am
new file mode 100644 (file)
index 0000000..7bbb929
--- /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=MovieRetitle
+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/movieretitle/po/MovieRetitle.pot b/movieretitle/po/MovieRetitle.pot
new file mode 100644 (file)
index 0000000..9c786bb
--- /dev/null
@@ -0,0 +1,75 @@
+# 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-14 21:40+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:51
+msgid "Cancel"
+msgstr ""
+
+#: ../src/plugin.py:20
+msgid "Change name..."
+msgstr ""
+
+#: ../src/plugin.py:91
+msgid "Choose target folder"
+msgstr ""
+
+#: ../src/plugin.py:72
+msgid "Description"
+msgstr ""
+
+#: ../src/plugin.py:281
+#, python-format
+msgid "Failed to move the movie %s to %s in the background"
+msgstr ""
+
+#: ../src/plugin.py:70
+msgid "Filename"
+msgstr ""
+
+#: ../src/plugin.py:68
+msgid "Location"
+msgstr ""
+
+#: ../src/plugin.py:50
+msgid "OK"
+msgstr ""
+
+#: ../src/plugin.py:288
+#, python-format
+msgid "Successfully moved the movie %s"
+msgstr ""
+
+#: ../src/plugin.py:128
+#, python-format
+msgid ""
+"Target file %s.ts already exist.\n"
+"Do you want to replace it?"
+msgstr ""
+
+#: ../src/plugin.py:240
+#, python-format
+msgid "The movie is moved in the background from %s to %s."
+msgstr ""
+
+#: ../src/plugin.py:132
+msgid "The target directory is not found. The file is not renamed."
+msgstr ""
+
+#: ../src/plugin.py:71
+msgid "Title"
+msgstr ""
diff --git a/movieretitle/po/de.po b/movieretitle/po/de.po
new file mode 100644 (file)
index 0000000..71828e2
--- /dev/null
@@ -0,0 +1,62 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Enigma 2 MovieRetitle Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-02-14 21:40+0100\n"
+"PO-Revision-Date: 2009-02-14 21:47+0100\n"
+"Last-Translator: Moritz Venn <moritz.venn@freaque.net>\n"
+"Language-Team: german <de@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Cancel"
+msgstr "Abbrechen"
+
+msgid "Change name..."
+msgstr "Umbenennen..."
+
+msgid "Choose target folder"
+msgstr "Zielverzeichnis wählen"
+
+msgid "Description"
+msgstr "Beschreibung"
+
+#, python-format
+msgid "Failed to move the movie %s to %s in the background"
+msgstr "Konnte den Film %s nicht im Hintergrund nach %s verschieben"
+
+msgid "Filename"
+msgstr "Dateiname"
+
+msgid "Location"
+msgstr "Ort"
+
+msgid "OK"
+msgstr "OK"
+
+#, python-format
+msgid "Successfully moved the movie %s"
+msgstr "Der Film %s wurde erfolgreich verschoben"
+
+#, python-format
+msgid ""
+"Target file %s.ts already exist.\n"
+"Do you want to replace it?"
+msgstr ""
+"Zieldatei %s.ts existiert bereits.\n"
+"Die Datei ersetzen?"
+
+#, python-format
+msgid "The movie is moved in the background from %s to %s."
+msgstr "Der Film wird im Hintergrund von %s nach %s verschoben."
+
+msgid "The target directory is not found. The file is not renamed."
+msgstr "Zielordner nicht gefunden. Die Datei wird nicht umbenannt."
+
+msgid "Title"
+msgstr "Titel"
index e69de29..8bdcb47 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("MovieRetitle", resolveFilename(SCOPE_PLUGINS, "Extensions/MovieRetitle/locale"))
+
+def _(txt):
+       t = gettext.dgettext("MovieRetitle", txt)
+       if t == txt:
+               print "[MovieRetitle] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
index 1756635..f012365 100644 (file)
@@ -1,3 +1,6 @@
+# for localized messages
+from . import _
+
 from Plugins.Plugin import PluginDescriptor
 from Screens.Screen import Screen
 from Screens.MessageBox import MessageBox