diff options
author | Dan Williams <dcbw@redhat.com> | 2014-12-08 09:00:30 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-12-08 12:39:29 -0600 |
commit | 078b945806b56ff663d051fdd9c228e7ef68d23e (patch) | |
tree | 85368cd4ff81b2f03845f7bec25f110e43f25f70 | |
parent | ca845c61117246e683002825b6e59e3d18cc8323 (diff) | |
download | network-manager-applet-078b945806b56ff663d051fdd9c228e7ef68d23e.tar.gz |
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
-rw-r--r-- | src/libnm-gtk/Makefile.am | 3 | ||||
-rw-r--r-- | src/libnm-gtk/init.c | 38 | ||||
-rw-r--r-- | src/libnm-gtk/nm-mobile-providers.c | 2 | ||||
-rw-r--r-- | src/libnm-gtk/nm-ui-utils.c | 2 | ||||
-rw-r--r-- | 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 1e5ac226..54cb0ac9 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 00000000..ffc50147 --- /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 0f976526..2cff1d47 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 170afd9a..f9b4d4fd 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 a4f70d44..60e6164e 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" |