[glib] Set up message translation for gdbus



commit 7efc12e0d55e582cdb689e40dbe3500c06f35196
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 12 12:26:26 2011 -0500

    Set up message translation for gdbus
    
    This was only halfway done before and not working.

 gio/gdbus-tool.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c
index dad24a4..9c6ff44 100644
--- a/gio/gdbus-tool.c
+++ b/gio/gdbus-tool.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <locale.h>
 
 #include <gio/gio.h>
 
@@ -359,7 +360,9 @@ connection_get_group (void)
                           N_("Options specifying the connection endpoint"),
                           NULL,
                           NULL);
+  g_option_group_set_translation_domain (g, GETTEXT_PACKAGE);
   g_option_group_add_entries (g, connection_entries);
+
   return g;
 }
 
@@ -569,7 +572,7 @@ handle_call (gint        *argc,
   o = g_option_context_new (NULL);
   g_option_context_set_help_enabled (o, FALSE);
   g_option_context_set_summary (o, _("Invoke a method on a remote object."));
-  g_option_context_add_main_entries (o, call_entries, NULL /* GETTEXT_PACKAGE*/);
+  g_option_context_add_main_entries (o, call_entries, GETTEXT_PACKAGE);
   g_option_context_add_group (o, connection_get_group ());
 
   complete_names = FALSE;
@@ -1195,7 +1198,7 @@ handle_introspect (gint        *argc,
     g_option_context_set_ignore_unknown_options (o, TRUE);
   g_option_context_set_help_enabled (o, FALSE);
   g_option_context_set_summary (o, _("Introspect a remote object."));
-  g_option_context_add_main_entries (o, introspect_entries, NULL /* GETTEXT_PACKAGE*/);
+  g_option_context_add_main_entries (o, introspect_entries, GETTEXT_PACKAGE);
   g_option_context_add_group (o, connection_get_group ());
 
   complete_names = FALSE;
@@ -1455,7 +1458,7 @@ handle_monitor (gint        *argc,
     g_option_context_set_ignore_unknown_options (o, TRUE);
   g_option_context_set_help_enabled (o, FALSE);
   g_option_context_set_summary (o, _("Monitor a remote object."));
-  g_option_context_add_main_entries (o, monitor_entries, NULL /* GETTEXT_PACKAGE*/);
+  g_option_context_add_main_entries (o, monitor_entries, GETTEXT_PACKAGE);
   g_option_context_add_group (o, connection_get_group ());
 
   complete_names = FALSE;
@@ -1646,6 +1649,21 @@ main (gint argc, gchar *argv[])
   gchar *completion_cur;
   gchar *completion_prev;
 
+  setlocale (LC_ALL, "");
+  textdomain (GETTEXT_PACKAGE);
+
+#ifdef G_OS_WIN32
+  gchar *tmp = _glib_get_locale_dir ();
+  bindtextdomain (GETTEXT_PACKAGE, tmp);
+  g_free (tmp);
+#else
+  bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
+#endif
+
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+
   ret = 1;
   completion_cur = NULL;
   completion_prev = NULL;



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