[ontv] Fix translations for messages defined in gtk builder files



commit 2bccfe67e15b02eac97b7f16451edee08ad4f06e
Author: Olof Kindgren <olki src gnome org>
Date:   Tue Jul 6 00:44:32 2010 +0200

    Fix translations for messages defined in gtk builder files
    
    gtk builder UI files are handled differently than glade files.
    Translations should now work again. As a side effect, all glade
    dependencies are now finally removed

 bin/ontv.in     |   12 +-
 data/ontv.glade | 1797 -------------------------------------------------------
 ontv/dialogs.py |   15 +-
 ontv/gui.py     |    5 -
 po/POTFILES.in  |   10 +-
 5 files changed, 28 insertions(+), 1811 deletions(-)
---
diff --git a/bin/ontv.in b/bin/ontv.in
index 06671eb..613ab8f 100644
--- a/bin/ontv.in
+++ b/bin/ontv.in
@@ -28,12 +28,19 @@ import os.path
 PYTHON_DIR = "@PYTHONDIR@"
 sys.path.insert(0, os.path.abspath(PYTHON_DIR))
 
-from gettext import gettext as _
-from ontv import DATA_DIR
+from ontv import DATA_DIR, NAME, LOCALE_DIR
 from ontv.ontv_core import OnTVCore
 import ontv.gui
 from optparse import OptionParser
 
+import locale
+locale.setlocale(locale.LC_ALL, '')
+locale.bindtextdomain(NAME.lower(), LOCALE_DIR)
+import gettext
+gettext.bindtextdomain(NAME.lower(), LOCALE_DIR)
+gettext.textdomain(NAME.lower())
+_ = gettext.gettext
+
 
 class OnTVStatusIcon:
 
@@ -42,6 +49,7 @@ class OnTVStatusIcon:
     self.ontv_core = OnTVCore(configure, debug, self.cb_status)
 
     self.builder = gtk.Builder()
+    builder.set_translation_domain(NAME.lower())
     ui_file = os.path.join(DATA_DIR, "status_icon.ui")
     self.builder.add_from_file(ui_file)
     self.builder.connect_signals(self)
diff --git a/ontv/dialogs.py b/ontv/dialogs.py
index c21d9e8..f759456 100644
--- a/ontv/dialogs.py
+++ b/ontv/dialogs.py
@@ -20,7 +20,6 @@
 
 import struct
 import os
-from gettext import gettext as _
 
 import gtk
 import gconf
@@ -32,7 +31,15 @@ import gui
 import utils
 from reminders import Reminder
 from assistant import GRABBERS, XMLTVAssistant
-from ontv import NAME, VERSION
+from ontv import NAME, VERSION, LOCALE_DIR
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+locale.bindtextdomain(NAME.lower(), LOCALE_DIR)
+import gettext
+gettext.bindtextdomain(NAME.lower(), LOCALE_DIR)
+gettext.textdomain(NAME.lower())
+_ = gettext.gettext
 
 COL_PATH   = 0
 COL_PIXBUF = 1
@@ -44,6 +51,7 @@ class ChannelDialog:
         self.channel = channel
         self.pd = pd
         builder = gtk.Builder()
+        builder.set_translation_domain(NAME.lower())
         builder.add_from_file(gui.channel_dialog_ui_file)
         builder.connect_signals(self)
         self.dialog = builder.get_object("channel_dialog")
@@ -171,6 +179,7 @@ class PreferencesDialog:
 
     def __get_widgets(self):
         builder = gtk.Builder()
+        builder.set_translation_domain(NAME.lower())
         builder.add_from_file(gui.preferences_dialog_ui_file)
 
         self.dialog = builder.get_object("preferences_dialog")
@@ -606,6 +615,7 @@ class PreferencesDialog:
 class ProgramDialog:
     def __init__(self, program):
         builder = gtk.Builder()
+        builder.set_translation_domain(NAME.lower())
         builder.add_from_file(gui.program_dialog_ui_file)
 
         self.dialog = builder.get_object("program_dialog")
@@ -643,6 +653,7 @@ class SearchDialog:
 
     def __init_ui(self):
         builder = gtk.Builder()
+        builder.set_translation_domain(NAME.lower())
         builder.add_from_file(gui.search_dialog_ui_file)
         
         self.dialog = builder.get_object("search_dialog")
diff --git a/ontv/gui.py b/ontv/gui.py
index e0baa16..30885f2 100644
--- a/ontv/gui.py
+++ b/ontv/gui.py
@@ -23,16 +23,11 @@ from gettext import gettext as _
 
 import gtk
 import gtk.gdk
-import gtk.glade
 
 from dialogs import ProgramDialog
 from reminders import Reminder
 from ontv import NAME, DATA_DIR, LOCALE_DIR, IMAGES_DIR
 
-gtk.glade.bindtextdomain(NAME.lower(), LOCALE_DIR)
-
-glade_file = os.path.join(DATA_DIR, "ontv.glade")
-
 about_dialog_ui_file = os.path.join(DATA_DIR, "about_dialog.ui")
 channel_dialog_ui_file = os.path.join(DATA_DIR, "channel_dialog.ui")
 program_dialog_ui_file = os.path.join(DATA_DIR, "program_dialog.ui")
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1ae4ce2..c598f2a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,14 +1,14 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 data/90-ontv.xml.in
-data/about_dialog.ui
+[type: gettext/glade]data/about_dialog.ui
 data/GNOME_OnTVApplet.server.in.in
 data/GNOME_OnTVApplet.xml
 data/ontv.schemas.in.in
-data/preferences_dialog.ui
-data/program_dialog.ui
-data/search_dialog.ui
-data/status_icon.ui
+[type: gettext/glade]data/preferences_dialog.ui
+[type: gettext/glade]data/program_dialog.ui
+[type: gettext/glade]data/search_dialog.ui
+[type: gettext/glade]data/status_icon.ui
 ontv/applet.py
 ontv/assistant.py
 ontv/channel.py



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]