[gnome-online-accounts] daemon, examples, identity: Call setlocale and gettext functions



commit f4d3f76dbb2cad74f5ab1620df9018c335ac9f6d
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sat Apr 23 15:48:51 2016 +0800

    daemon, examples, identity: Call setlocale and gettext functions
    
    Calling these functions is required to make message translation work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765455

 src/daemon/main.c             |    7 +++++++
 src/examples/add-pocket.c     |    3 +++
 src/examples/lastfm-shout.c   |    3 +++
 src/examples/list-accounts.c  |    4 ++++
 src/examples/list-providers.c |    4 ++++
 src/goaidentity/main.c        |    7 +++++++
 6 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/daemon/main.c b/src/daemon/main.c
index cd4c66a..333ae07 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -20,8 +20,10 @@
 
 #include <glib-unix.h>
 
+#include <locale.h>
 #include <signal.h>
 #include <gio/gio.h>
+#include <libintl.h>
 
 #include "goadaemon.h"
 
@@ -100,6 +102,11 @@ main (int    argc,
   opt_context = NULL;
   name_owner_id = 0;
 
+  setlocale (LC_ALL, "");
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
   opt_context = g_option_context_new ("GNOME Online Accounts daemon");
   g_option_context_add_main_entries (opt_context, opt_entries, NULL);
   error = NULL;
diff --git a/src/examples/add-pocket.c b/src/examples/add-pocket.c
index 5c45404..48c1caf 100644
--- a/src/examples/add-pocket.c
+++ b/src/examples/add-pocket.c
@@ -20,6 +20,7 @@
 #define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
 
+#include <locale.h>
 #include <rest/rest-proxy.h>
 #include <rest/rest-proxy-call.h>
 
@@ -37,6 +38,8 @@ main (int argc, char **argv)
   const char *url;
   const char *tweet_id = NULL;
 
+  setlocale (LC_ALL, "");
+
   if (argc != 2 && argc != 3) {
     g_print ("Usage: %s URL [TWEET ID]\n", argv[0]);
     return 1;
diff --git a/src/examples/lastfm-shout.c b/src/examples/lastfm-shout.c
index 25a796c..e2bc8f9 100644
--- a/src/examples/lastfm-shout.c
+++ b/src/examples/lastfm-shout.c
@@ -21,6 +21,7 @@
 #define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
 
+#include <locale.h>
 #include <rest/rest-proxy.h>
 #include <rest/rest-proxy-call.h>
 
@@ -39,6 +40,8 @@ main (int argc, char **argv)
   const char *user;
   const char *message = NULL;
 
+  setlocale (LC_ALL, "");
+
   if (argc != 2 && argc != 3) {
     g_print ("Usage: %s USER [MESSAGE]\n", argv[0]);
     return 1;
diff --git a/src/examples/list-accounts.c b/src/examples/list-accounts.c
index 777acdf..3c11818 100644
--- a/src/examples/list-accounts.c
+++ b/src/examples/list-accounts.c
@@ -20,6 +20,8 @@
 #define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
 
+#include <locale.h>
+
 int
 main (int argc, char **argv)
 {
@@ -28,6 +30,8 @@ main (int argc, char **argv)
   GList *accounts, *l;
   GoaAccount *account;
 
+  setlocale (LC_ALL, "");
+
   client = goa_client_new_sync (NULL, &error);
   if (!client) {
     g_error ("Could not create GoaClient: %s", error->message);
diff --git a/src/examples/list-providers.c b/src/examples/list-providers.c
index 4bc222d..94f8c9f 100644
--- a/src/examples/list-providers.c
+++ b/src/examples/list-providers.c
@@ -21,6 +21,8 @@
 #define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
 #include <goabackend/goabackend.h>
 
+#include <locale.h>
+
 typedef struct
 {
   GMainLoop *loop;
@@ -46,6 +48,8 @@ main (int argc, char **argv)
   GoaProvider *provider;
   GList *l;
 
+  setlocale (LC_ALL, "");
+
   data.loop = g_main_loop_new (NULL, FALSE);
   goa_provider_get_all (get_all_cb, &data);
   g_main_loop_run (data.loop);
diff --git a/src/goaidentity/main.c b/src/goaidentity/main.c
index 3ab0403..75ef5e0 100644
--- a/src/goaidentity/main.c
+++ b/src/goaidentity/main.c
@@ -20,7 +20,9 @@
 
 #include <glib-unix.h>
 
+#include <locale.h>
 #include <gio/gio.h>
+#include <libintl.h>
 
 #include "goaidentityservice.h"
 
@@ -33,6 +35,11 @@ main (int    argc,
   GError *error;
   int ret = 1;
 
+  setlocale (LC_ALL, "");
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
   loop = g_main_loop_new (NULL, FALSE);
   service = goa_identity_service_new ();
 


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