From 361792d9aa11f7affdabd844998390d16ed5b354 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Tue, 25 Mar 2014 22:51:06 -0400 Subject: [PATCH] Add autopoint support to regenerate gettext files Remove gettext autogenerated/copied files in 'make maintainer-clean'. --- Makefile.am | 5 ++++- autogen.sh | 18 ++++++++++++++++++ configure.ac | 8 ++------ po/Makevars | 7 +++++++ src/Makefile.am | 6 ++++-- src/common.h | 10 +++++++--- src/main.c | 6 +++--- 7 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 po/Makevars diff --git a/Makefile.am b/Makefile.am index a60fe2f..684e672 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,8 @@ CLEANFILES = *~ MAINTAINERCLEANFILES = \ ChangeLog \ + INSTALL \ + ABOUT-NLS \ $(top_srcdir)/Makefile.in \ $(top_srcdir)/aclocal.m4 \ $(top_srcdir)/configure \ @@ -29,7 +31,8 @@ MAINTAINERCLEANFILES = \ $(ac_aux_dir)/config.guess \ $(ac_aux_dir)/config.sub \ $(ac_aux_dir)/ltmain.sh \ - $(ac_aux_dir)/compile + $(ac_aux_dir)/compile \ + $(ac_aux_dir)/config.rpath changelog: @if test -d $(srcdir)/.git; then \ diff --git a/autogen.sh b/autogen.sh index 8d54a63..87fb83d 100755 --- a/autogen.sh +++ b/autogen.sh @@ -7,6 +7,9 @@ set -e # To test that we are really in the top-level directory TEST_FILE=src/grip.c +# Where to copy gettext.h +GETTEXT_INC_DIR=src + test -f ${TEST_FILE} || { echo "Error: You must run this script in the top-level project directory" exit 1 @@ -23,4 +26,19 @@ touch ChangeLog autoreconf -v --install --force +# Update gettext files +if [ -f po/Makevars ]; then + rm po/Makevars.template +fi + +# If po/POTFILES.in is not present, po/Makefile won't be generated when running +# ./configure +if [ ! -f po/POTFILES.in ]; then + touch po/POTFILES.in +fi + +if [ ! -f ${GETTEXT_INC_DIR}/gettext.h ]; then + cp /usr/share/gettext/gettext.h ${GETTEXT_INC_DIR} +fi + rm -rf autom4te.cache diff --git a/configure.ac b/configure.ac index e8496e4..d78a628 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,8 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/main.c) AM_INIT_AUTOMAKE(check-news -Wall std-options) AM_SILENT_RULES([yes]) +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.18.1]) AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h:config.h.in) @@ -51,12 +53,6 @@ dnl check for curl AC_CHECK_HEADER(curl/curl.h, [], [AC_MSG_ERROR(libcurl headers are missing)]) AC_CHECK_LIB(curl,curl_global_init, [LIBS="$LIBS `curl-config --libs`"], [AC_MSG_ERROR(curl libs are missing)]) -GETTEXT_PACKAGE=grip-2.2 -AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) -ALL_LINGUAS="fr de zh_CN zh_HK zh_TW ja pt_BR ru es ca it be fi bg nl hu pl_PL" -AM_GLIB_GNU_GETTEXT - dnl do cdparanoia check if test "$enable_cdpar" = "yes"; then LIBS="$LIBS -lm" diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..5a4168b --- /dev/null +++ b/po/Makevars @@ -0,0 +1,7 @@ +DOMAIN = $(PACKAGE) +subdir = po +top_builddir = .. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ +COPYRIGHT_HOLDER = Hugo Villeneuve +MSGID_BUGS_ADDRESS = $(PACKAGE_BUGREPORT) +EXTRA_LOCALE_CATEGORIES = diff --git a/src/Makefile.am b/src/Makefile.am index 3f12495..5ef9437 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ AM_CPPFLAGS = \ -I$(includedir) \ -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \ -DG_LOG_DOMAIN=\"grip\" \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + -DLOCALEDIR=\"$(localedir)\" \ -I../intl -I$(top_srcdir)/intl \ -DPREFIX=\""$(prefix)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ @@ -57,4 +57,6 @@ grip_LDADD = @TERMINAL_WIDGET_LIBS@ $(CDPAR_LIBS) $(ID3_LIBS) CLEANFILES = *~ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = \ + Makefile.in \ + gettext.h diff --git a/src/common.h b/src/common.h index 738e64f..bec7609 100644 --- a/src/common.h +++ b/src/common.h @@ -20,14 +20,18 @@ * USA */ +#include #include +#include +#include #include #include #include -#include -#include -#define _(STRING) gettext(STRING) +#include "gettext.h" + +#define _(String) gettext(String) +#define N_(String) gettext_noop(String) /* Routines from main.c */ void Debug(char *fmt,...); diff --git a/src/main.c b/src/main.c index fb886ab..74ff8f7 100644 --- a/src/main.c +++ b/src/main.c @@ -156,8 +156,8 @@ int Cmain(int argc, char* argv[]) /* setup locale, i18n */ gtk_set_locale(); - bindtextdomain(GETTEXT_PACKAGE,GNOMELOCALEDIR); - textdomain(GETTEXT_PACKAGE); + bindtextdomain(PACKAGE_TARNAME, LOCALEDIR); + textdomain(PACKAGE_TARNAME); gtk_init(&argc, &argv); context = poptGetContext(NULL, argc, (const char **) argv, options, 0); @@ -173,7 +173,7 @@ int Cmain(int argc, char* argv[]) exit(1); } - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF8"); + bind_textdomain_codeset(PACKAGE_TARNAME, "UTF8"); setenv("CHARSET","UTF-8",1); do_debug=verbose; -- 2.20.1