From 78debdea8400a1ca9de6db358388fb1648bf3318 Mon Sep 17 00:00:00 2001 From: Andras Mohari Date: Wed, 3 Oct 2007 11:43:43 +0200 Subject: [PATCH] Added preliminary support for Glade translations (as suggested by Lennon Cook). We check for the presence of libintl.h and use the bindtextdomain() call to tell Glade where to find its catalogs. Right now the $APP_DIR/Messages directory must be set up manually so that the catalogs can be found, eg.: . |-- hu | `-- LC_MESSAGES | `-- ROX-Filer.mo -> ../../hu.gmo `-- hu.gmo This seems to work fine when ROX-Filer is configured to use the LANG environment variable. Changing languages manually is not supported though, since we should change the locale on the fly, which does not seem to be a good idea to me... --- ROX-Filer/src/config.h.in | 1 + ROX-Filer/src/configure.in | 2 +- ROX-Filer/src/gui_support.c | 2 +- ROX-Filer/src/i18n.c | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ROX-Filer/src/config.h.in b/ROX-Filer/src/config.h.in index fc6b836d..6a8772ac 100644 --- a/ROX-Filer/src/config.h.in +++ b/ROX-Filer/src/config.h.in @@ -19,6 +19,7 @@ #undef HAVE_STATVFS #undef HAVE_SYS_VFS_H #undef HAVE_SYS_STATVFS_H +#undef HAVE_LIBINTL_H #undef HAVE_MBRTOWC #undef HAVE_WCTYPE_H diff --git a/ROX-Filer/src/configure.in b/ROX-Filer/src/configure.in index 539ddc82..99e05562 100644 --- a/ROX-Filer/src/configure.in +++ b/ROX-Filer/src/configure.in @@ -127,7 +127,7 @@ dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h mntent.h sys/ucred.h sys/mntent.h apsymbols.h apbuild/apsymbols.h sys/statvfs.h sys/vfs.h wctype.h) +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h mntent.h sys/ucred.h sys/mntent.h apsymbols.h apbuild/apsymbols.h sys/statvfs.h sys/vfs.h wctype.h libintl.h) AC_CHECK_HEADER([X11/SM/SMlib.h], [], [AC_MSG_ERROR([Session management library (libsm) missing. It is part of the X server distribution. Try installing the libsm-dev package.])] diff --git a/ROX-Filer/src/gui_support.c b/ROX-Filer/src/gui_support.c index f767d274..3fc190a5 100644 --- a/ROX-Filer/src/gui_support.c +++ b/ROX-Filer/src/gui_support.c @@ -1581,7 +1581,7 @@ GladeXML *get_glade_xml(const char *component) char *path; path = g_build_filename(app_dir, "Templates.glade", NULL); - widgets = glade_xml_new(path, component, NULL); + widgets = glade_xml_new(path, component, "ROX-Filer"); if (widgets == NULL) g_warning("Failed to load widget '%s' from '%s'", diff --git a/ROX-Filer/src/i18n.c b/ROX-Filer/src/i18n.c index dabe8568..08e96c95 100644 --- a/ROX-Filer/src/i18n.c +++ b/ROX-Filer/src/i18n.c @@ -23,6 +23,9 @@ #include #include #include +#ifdef HAVE_LIBINTL_H +#include +#endif #include "global.h" @@ -208,6 +211,12 @@ static void set_trans(const guchar *lang) current_lang = lang2; +#ifdef HAVE_LIBINTL_H + path = g_strdup_printf("%s/Messages", app_dir); + bindtextdomain("ROX-Filer", path); + g_free(path); +#endif + path = g_strdup_printf("%s/Messages/%s.gmo", app_dir, current_lang); if (!file_exists(path) && strchr(current_lang, '_')) { -- 2.11.4.GIT