[Xfce4-commits] <libxfce4util:xfce-4.6> Fix broken translations in applications using libxfce4util.
Nick Schermer
noreply at xfce.org
Wed May 12 22:38:01 CEST 2010
Updating branch refs/heads/xfce-4.6
to a70bd52c7dfece4c4d26158d7193a9c55366e980 (commit)
from c2ffa2fdde75aeb2b8cd92e09e8e57d08facf16d (commit)
commit a70bd52c7dfece4c4d26158d7193a9c55366e980
Author: Nick Schermer <nick at xfce.org>
Date: Wed May 12 22:09:17 2010 +0200
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.
Conflicts:
configure.in.in
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 1be26b9..9a19fce 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -99,8 +99,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])
-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 15fc0ce..ccd4b79 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