Add gettext support
authorDan Winship <danw@gnome.org>
Fri, 13 Apr 2012 00:17:06 +0000 (20:17 -0400)
committerDan Winship <danw@gnome.org>
Tue, 17 Apr 2012 13:54:08 +0000 (09:54 -0400)
There were already error messages in soup-request.c and
soup-requester.c marked for translation, and we'll be adding more
soon.

.gitignore
Makefile.am
configure.ac
libsoup/Makefile.am
libsoup/soup-request.c
libsoup/soup-requester.c
libsoup/soup-session.c
po/LINGUAS [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
tests/test-utils.c

index 8d77197..111bffd 100644 (file)
@@ -50,11 +50,15 @@ libsoup/SoupGNOME-2.4.typelib
 libtool
 ltmain.sh
 m4/gtk-doc.m4
+m4/intltool.m4
 m4/libtool.m4
 m4/lt*.m4
 missing
-python/COPYING
-python/m4
+mkinstalldirs
+po/libsoup.pot
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it
 stamp-h1
 tests/*-test
 tests/date
index 8b86fb7..6b9c6a8 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-SUBDIRS = libsoup tests docs
+SUBDIRS = libsoup po tests docs
 
 EXTRA_DIST =                   \
        libsoup-2.4.pc.in       \
index 4ff639e..84d3ec6 100644 (file)
@@ -103,6 +103,15 @@ esac
 AC_MSG_RESULT([$os_win32])
 AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
 
+dnl ************************
+dnl *** gettext/intltool ***
+dnl ************************
+IT_PROG_INTLTOOL([0.35.0])
+GETTEXT_PACKAGE=libsoup
+AC_SUBST([GETTEXT_PACKAGE])
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The gettext domain name])
+AM_GLIB_GNU_GETTEXT
+
 dnl *******************
 dnl *** Misc checks ***
 dnl *******************
@@ -347,6 +356,8 @@ AC_CONFIG_FILES([
        Makefile
        libsoup-zip
        libsoup/Makefile
+       po/Makefile.in
+       po/Makefile
        tests/Makefile
        tests/httpd.conf
        docs/Makefile
index aa13eec..2b36a86 100644 (file)
@@ -8,6 +8,7 @@ endif
 
 INCLUDES =                             \
        -DG_LOG_DOMAIN=\"libsoup\"      \
+       -DLOCALEDIR=\"$(localedir)\"    \
        -I$(top_srcdir)                 \
        $(SOUP_DEBUG_FLAGS)             \
        $(SOUP_MAINTAINER_FLAGS)        \
index 06fe7ff..5e97841 100644 (file)
@@ -25,7 +25,7 @@
 #include <config.h>
 #endif
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 
 #define LIBSOUP_USE_UNSTABLE_REQUEST_API
 
index d71d447..5897ed2 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 
 #define LIBSOUP_USE_UNSTABLE_REQUEST_API
 
index 2cfcc27..fa95f7e 100644 (file)
@@ -13,6 +13,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <glib/gi18n-lib.h>
+
 #include "soup-auth.h"
 #include "soup-auth-basic.h"
 #include "soup-auth-digest.h"
  * #SoupSessionSync.
  **/
 
+static void
+soup_init (void)
+{
+       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+}
+
 typedef struct {
        SoupURI     *uri;
        SoupAddress *addr;
@@ -132,7 +143,9 @@ static void auth_manager_authenticate (SoupAuthManager *manager,
 
 #define SOUP_SESSION_USER_AGENT_BASE "libsoup/" PACKAGE_VERSION
 
-G_DEFINE_ABSTRACT_TYPE (SoupSession, soup_session, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (SoupSession, soup_session, G_TYPE_OBJECT,
+                                 soup_init ();
+                                 )
 
 enum {
        REQUEST_QUEUED,
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..c43b943
--- /dev/null
@@ -0,0 +1,2 @@
+libsoup/soup-request.c
+libsoup/soup-requester.c
index 47f1db0..fee671a 100644 (file)
@@ -5,6 +5,7 @@
 #include "test-utils.h"
 #include "libsoup/soup.h"
 
+#include <locale.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -81,6 +82,7 @@ test_init (int argc, char **argv, GOptionEntry *entries)
        GError *error = NULL;
        GTlsBackend *tls_backend;
 
+       setlocale (LC_ALL, "");
        g_type_init ();
 
        name = strrchr (argv[0], '/');