[gcab] Add translation framework



commit 96d5c7c6a2eb1c2fd6becae3075bf0f9a459cf19
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Fri Dec 21 19:24:48 2012 +0100

    Add translation framework

 Makefile.am    |    3 +++
 autogen.sh     |    3 ++-
 configure.ac   |   10 ++++++++++
 gcab.c         |    8 +++++++-
 po/LINGUAS     |    1 +
 po/POTFILES.in |    4 ++++
 6 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3dfedf7..a889461 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,9 +5,12 @@ DISTCLEANFILES =
 ACLOCAL_AMFLAGS = -I m4
 AM_MAKEFLAGS = --no-print-directory
 
+SUBDIRS = po
+
 AM_CPPFLAGS =					\
         -I$(top_srcdir)				\
         -DG_LOG_DOMAIN=\"gcab\"			\
+	-DLOCALEDIR="\"$(datadir)/locale\""	\
 	$(NULL)
 
 AM_LDFLAGS = -lz $(GLIB2_LIBS)
diff --git a/autogen.sh b/autogen.sh
index 0e54ade..ef1012c 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -7,7 +7,8 @@ test -z "$srcdir" && srcdir=.
 mkdir -p "$srcdir/m4"
 
 autoreconf -v --force --install
+intltoolize -f
 
 if [ -z "$NOCONFIGURE" ]; then
-    "$srcdir"/configure ${1+"$@"}
+    "$srcdir"/configure "$@"
 fi
diff --git a/configure.ac b/configure.ac
index 0a6e64f..8d1784d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,15 @@ LT_INIT([win32-dll disable-fast-install])
 PKG_PROG_PKG_CONFIG
 GOBJECT_INTROSPECTION_CHECK([0.9.4])
 
+# i18 support
+IT_PROG_INTLTOOL(0.40.0)
+
+GETTEXT_PACKAGE=AC_PACKAGE_NAME
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The name of the gettext domain])
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.17])
+
 AM_MISSING_PROG([AUTOM4TE], [autom4te])
 AC_CONFIG_TESTDIR([.])
 AC_CONFIG_FILES([atlocal])
@@ -44,6 +53,7 @@ AC_OUTPUT([
   Makefile
   gcab.1
   libgcab-1.0.pc
+  po/Makefile.in
 ])
 
 AC_MSG_NOTICE([
diff --git a/gcab.c b/gcab.c
index 4a6d265..cdc7dc8 100644
--- a/gcab.c
+++ b/gcab.c
@@ -3,6 +3,8 @@
 #include <stdlib.h>
 #include <libgcab.h>
 #include <glib/gprintf.h>
+#include <locale.h>
+#include <glib/gi18n.h>
 
 static void
 gcab_error (const gchar *format, ...)
@@ -75,7 +77,11 @@ main (int argc, char *argv[])
         { NULL }
     };
 
-    g_type_init ();
+    setlocale (LC_ALL, "");
+    textdomain (GETTEXT_PACKAGE);
+    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
     g_set_prgname (PACKAGE_NAME);
 
     context = g_option_context_new (_("- create a Cabinet file"));
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..1facba0
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1 @@
+# keep this list sorted
\ No newline at end of file
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..08fe625
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,4 @@
+gcab.c
+libgcab/gcab-cabinet.c
+libgcab/gcab-file.c
+libgcab/gcab-folder.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]