[Xfce4-commits] <libxfce4util:master> Fix broken translations in applications using libxfce4util.
Nick Schermer
noreply at xfce.org
Tue Feb 9 13:16:03 CET 2010
Updating branch refs/heads/master
to 09c1a068b2ec41fafe4e9be2683f6525bda20085 (commit)
from 7d95bf8ad827dd5d7089fd9923771658e706c7ab (commit)
commit 09c1a068b2ec41fafe4e9be2683f6525bda20085
Author: Nick Schermer <nick at xfce.org>
Date: Tue Feb 9 13:12:25 2010 +0100
Fix broken translations in applications using libxfce4util.
Because we called textdomain() in the private i18n init
function, we make libxfce4util the default translation
domain, instead of only registering the translation
path. See terminal bug #5842.
configure.in.in | 5 +++--
libxfce4util/libxfce4util-private.c | 28 ++++++++++++++++++++++++++--
libxfce4util/xfce-i18n.c | 3 +++
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/configure.in.in b/configure.in.in
index ae0c272..9e96e2d 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -101,8 +101,9 @@ dnl ***************************************
AC_HEADER_STDC()
AC_CHECK_HEADERS([err.h errno.h grp.h limits.h locale.h pwd.h \
signal.h sys/stat.h sys/types.h sys/utsname.h \
- sys/wait.h time.h unistd.h varargs.h])
-AC_CHECK_FUNCS([gethostname getpwnam setenv setlocale strdup unsetenv])
+ sys/wait.h time.h unistd.h varargs.h libintl.h])
+AC_CHECK_FUNCS([gethostname getpwnam setenv setlocale strdup unsetenv\
+ bind_textdomain_codeset])
dnl ******************************
dnl *** Check for i18n support ***
diff --git a/libxfce4util/libxfce4util-private.c b/libxfce4util/libxfce4util-private.c
index ccecd40..13cb2a5 100644
--- a/libxfce4util/libxfce4util-private.c
+++ b/libxfce4util/libxfce4util-private.c
@@ -23,6 +23,13 @@
#include <config.h>
#endif
+#ifdef HAVE_LIBINTL_H
+#include <libintl.h>
+#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
#include <libxfce4util/libxfce4util-private.h>
#include <libxfce4util/libxfce4util-alias.h>
@@ -31,12 +38,29 @@
/**
* _xfce_i18n_init:
*
- * Initializes the libxfce4util i18n support.
+ * Initializes the libxfce4util i18n support. We don't call
+ * xfce_textdomain() here because we don't want to become the
+ * default domain for future gettext() calls (which is what
+ * textdomain does), because then we break apps that make
+ * gettext calls afterwards.
**/
void
_xfce_i18n_init (void)
{
- xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, NULL);
+ static gboolean inited = FALSE;
+
+ if (G_UNLIKELY (!inited))
+ {
+ inited = TRUE;
+
+ /* bind the text domain for the package to the given directory */
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+
+ /* setup the encoding for the package */
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+ }
}
diff --git a/libxfce4util/xfce-i18n.c b/libxfce4util/xfce-i18n.c
index 9fe3739..34d096c 100644
--- a/libxfce4util/xfce-i18n.c
+++ b/libxfce4util/xfce-i18n.c
@@ -27,6 +27,9 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
+#ifdef HAVE_LIBINTL_H
+#include <libintl.h>
+#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
More information about the Xfce4-commits
mailing list