[network-manager-applet] libnm-gtk: fix library gettext usage (bgo #741215)



commit 078b945806b56ff663d051fdd9c228e7ef68d23e
Author: Dan Williams <dcbw redhat com>
Date:   Mon Dec 8 09:00:30 2014 -0600

    libnm-gtk: fix library gettext usage (bgo #741215)
    
    Libraries need to include <gi18n-lib.h>, not <gi18n.h>, so that _()
    will get defined to "dgettext (GETTEXT_DOMAIN, string)" rather than
    "gettext (string)" (which will use the program's default domain, which
    works fine for programs in the network-manager-applet tree, but not for
    external users). Likewise, we need to call bindtextdomain() so that
    gettext can find the translations if the library is installed in a
    different prefix from the program using it (and
    bind_textdomain_codeset(), so it will know the translations are in
    UTF-8 even if the locale isn't).
    
    (based on NM commit 53f5e9afa466b0b1517cbac208ed01ab8f4b6274)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741215

 src/libnm-gtk/Makefile.am              |    3 +-
 src/libnm-gtk/init.c                   |   38 ++++++++++++++++++++++++++++++++
 src/libnm-gtk/nm-mobile-providers.c    |    2 +-
 src/libnm-gtk/nm-ui-utils.c            |    2 +-
 src/libnm-gtk/nm-vpn-password-dialog.c |    2 +-
 5 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/src/libnm-gtk/Makefile.am b/src/libnm-gtk/Makefile.am
index 1e5ac22..54cb0ac 100644
--- a/src/libnm-gtk/Makefile.am
+++ b/src/libnm-gtk/Makefile.am
@@ -21,7 +21,8 @@ libnm_gtk_la_SOURCES = \
        nm-mobile-wizard.c \
        nm-ui-utils.c \
        nm-mobile-providers.c \
-       nm-vpn-password-dialog.c
+       nm-vpn-password-dialog.c \
+       init.c
 
 libnm_gtk_la_CFLAGS = \
        $(GTK_CFLAGS) \
diff --git a/src/libnm-gtk/init.c b/src/libnm-gtk/init.c
new file mode 100644
index 0000000..ffc5014
--- /dev/null
+++ b/src/libnm-gtk/init.c
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2014 Red Hat, Inc.
+ */
+
+#include "config.h"
+
+#include <libintl.h>
+#include <glib/gi18n-lib.h>
+
+static void __attribute__((constructor))
+_libnm_gtk_init (void)
+{
+       static gboolean initialized = FALSE;
+
+       if (initialized)
+               return;
+       initialized = TRUE;
+
+       bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);
+       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+}
+
diff --git a/src/libnm-gtk/nm-mobile-providers.c b/src/libnm-gtk/nm-mobile-providers.c
index 0f97652..2cff1d4 100644
--- a/src/libnm-gtk/nm-mobile-providers.c
+++ b/src/libnm-gtk/nm-mobile-providers.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 
 #include "nm-mobile-providers.h"
 
diff --git a/src/libnm-gtk/nm-ui-utils.c b/src/libnm-gtk/nm-ui-utils.c
index 170afd9..f9b4d4f 100644
--- a/src/libnm-gtk/nm-ui-utils.c
+++ b/src/libnm-gtk/nm-ui-utils.c
@@ -24,7 +24,7 @@
 
 #include <string.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gudev/gudev.h>
 
 #include <nm-device.h>
diff --git a/src/libnm-gtk/nm-vpn-password-dialog.c b/src/libnm-gtk/nm-vpn-password-dialog.c
index a4f70d4..60e6164 100644
--- a/src/libnm-gtk/nm-vpn-password-dialog.c
+++ b/src/libnm-gtk/nm-vpn-password-dialog.c
@@ -24,7 +24,7 @@
 
 #include <config.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
 #include "nm-vpn-password-dialog.h"


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