From 7d75b932abdccc1d6630c6f76e526979f0b00fb2 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 22 Sep 2011 15:50:50 +0100 Subject: [PATCH] Add translation support Signed-off-by: David Woodhouse --- .gitignore | 9 +++++++++ Makefile.am | 3 +++ autogen.sh | 9 +++++---- configure.ac | 9 ++++++++- main.c | 5 +++++ openconnect-internal.h | 7 ++++++- openconnect.html | 3 ++- po/LINGUAS | 0 po/POTFILES.in | 12 ++++++++++++ 9 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 po/LINGUAS create mode 100644 po/POTFILES.in diff --git a/.gitignore b/.gitignore index af4828fb..048d69c1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,12 @@ version.c openconnect nm-openconnect-auth-dialog Make.config +/po/Makefile +/po/Makefile.in +/po/Makefile.in.in +/po/*.gmo +/po/*.mo +/po/POTFILES +/po/.intltool-merge-cache +/po/stamp-it +/po/openconnect.pot diff --git a/Makefile.am b/Makefile.am index 8f70ecf1..deba8dd9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,7 @@ +if USE_NLS +SUBDIRS = po +endif lib_LTLIBRARIES = libopenconnect.la bin_PROGRAMS = openconnect diff --git a/autogen.sh b/autogen.sh index 885c0dfa..3938fbef 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,7 @@ #!/bin/sh -aclocal && \ - libtoolize --automake --copy --force && \ - automake --foreign --add-missing && \ - autoconf +intltoolize --force --copy --automake && \ + aclocal && \ + libtoolize --automake --copy --force && \ + automake --foreign --add-missing && \ + autoconf diff --git a/configure.ac b/configure.ac index 53027273..012469f7 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,13 @@ AC_LANG_C AM_INIT_AUTOMAKE([foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +IT_PROG_INTLTOOL +AC_SUBST(GETTEXT_PACKAGE, [openconnect]) +AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"]) +if (test "$USE_NLS" = "yes"); then + AC_DEFINE(ENABLE_NLS, 1) +fi + AS_COMPILER_FLAGS(CFLAGS, "-Wall -Wextra @@ -77,4 +84,4 @@ AC_CHECK_LIB(ssl, dtls1_stop_timer, AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function]), ,,${OPENSSL_LIBS}) -AC_OUTPUT(Makefile openconnect.pc) +AC_OUTPUT(Makefile openconnect.pc po/Makefile.in) diff --git a/main.c b/main.c index 26370074..ca54f947 100644 --- a/main.c +++ b/main.c @@ -236,6 +236,11 @@ int main(int argc, char **argv) char *pidfile = NULL; FILE *fp = NULL; +#ifdef ENABLE_NLS + setlocale(LC_ALL, ""); + textdomain("openconnect"); +#endif + openconnect_init_openssl(); vpninfo = malloc(sizeof(*vpninfo)); diff --git a/openconnect-internal.h b/openconnect-internal.h index 1a660a0b..b03153f7 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -39,7 +39,12 @@ #ifdef LIBPROXY_HDR #include LIBPROXY_HDR #endif - +#ifdef ENABLE_NLS +#include +#define _(s) gettext(s) +#else +#define _(s) s +#endif /****************************************************************************/ diff --git a/openconnect.html b/openconnect.html index c308b910..145eb866 100644 --- a/openconnect.html +++ b/openconnect.html @@ -183,6 +183,7 @@

Release Notes / Changelog

  • OpenConnect HEAD
      +
    • Add localisation support.
    • Fix build on Debian systems where dtls1_stop_timer() is not available.
    • Fix libproxy detection.
    • Enable a useful set of compiler warnings by default.
    • @@ -508,6 +509,6 @@

      FreeBSD


      David Woodhouse <dwmw2@infradead.org>
      -Last modified: Thu Sep 22 14:39:12 BST 2011 +Last modified: Thu Sep 22 15:51:17 BST 2011 diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 00000000..e69de29b diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..5196ad9a --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,12 @@ +# List of source files containing translatable strings. +# Please keep this list in alphabetic order. +[encoding: UTF-8] +auth.c +cstp.c +dtls.c +http.c +main.c +mainloop.c +ssl.c +tun.c +xml.c