From f7ee773acd0b9e2bec95992d238cc479cd75497a Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 20 Apr 2023 12:55:50 -0400 Subject: build: gettextize --- diff --git a/.gitignore b/.gitignore index 12aa9dd..2ff673f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ *~ *.orig -# Files generated by aclocal, autoconf, and automake +# Files generated by gettextize, aclocal, autoconf, and automake +/ABOUT-NLS /aclocal.m4 /autom4te.cache/ /configure diff --git a/Makefile.am b/Makefile.am index 68131cc..345cd25 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,7 +55,7 @@ opkg_opk_LINK = $(LINK) version.c EXTRA_opkg_opk_DEPENDENCIES = version.c CLEANFILES = version.c CONFIG_CLEAN_FILES = -EXTRA_DIST = autogen.sh +EXTRA_DIST = build-aux/config.rpath autogen.sh version.c: $(opkg_opk_OBJECTS) $(opkg_opk_DEPENDENCIES) $(AM_V_GEN)printf 'const char *PACKAGE_VERSION_GIT = "%s";\n' \ @@ -103,3 +103,5 @@ release: $(PACKAGE) $(VERSION) '$(PACKAGE_NAME)' include $(top_srcdir)/src/local.mk + +SUBDIRS = . po diff --git a/autogen.sh b/autogen.sh index 28c30e4..f334959 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,7 +2,7 @@ # # Script to generate the build system. # -# Copyright (C) 2013 Patrick McDermott +# Copyright (C) 2013, 2019 Patrick McDermott # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -19,6 +19,14 @@ srcdir="${0%/*}" cat >ChangeLog <<-EOF This file is generated upon release. Run \`git log\` for a list of changes. EOF + # Force gettextize to be non-interactive. Stupid but necessary. + LC_ALL=C expect -f - <<-EOF + spawn gettextize --force --no-changelog + expect "Press Return to acknowledge the previous * paragraphs." + send "\n" + EOF + # This file contains a huge outdated matrix of unrelated packages. + >ABOUT-NLS aclocal autoconf autoheader diff --git a/configure.ac b/configure.ac index 3c0924b..f600715 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,12 @@ AM_SILENT_RULES([yes]) AM_CONDITIONAL([IN_GIT], [test -d "${srcdir}/.git" && command -v git >/dev/null 2>&1]) +GETTEXT_PACKAGE="${PACKAGE}" +AC_SUBST([GETTEXT_PACKAGE]) +AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], + [Define the gettext package to be used.]) +AM_GNU_GETTEXT([external]) + save_CFLAGS="${CFLAGS-}" AC_PROG_CC() AM_PROG_CC_C_O() @@ -106,6 +112,6 @@ if test "x${address_sanitization}" = 'xyes'; then AC_SUBST([ASAN_CFLAGS]) fi -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile po/Makefile.in]) AC_CONFIG_HEADERS([config.h]) AC_OUTPUT() diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 0000000..c7e2124 --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,8 @@ +/gettext.m4 +/iconv.m4 +/lib-ld.m4 +/lib-link.m4 +/lib-prefix.m4 +/nls.m4 +/po.m4 +/progtest.m4 diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 index 0000000..532f823 --- /dev/null +++ b/po/.gitignore @@ -0,0 +1,11 @@ +/Makefile.in.in +/Makevars.template +/Rules-quot +/*.sed +/POTFILES +/*.pot +/*.po +/*.mo +/*@boldquot.header +/*@quot.header +/stamp-po diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..0cddd98 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,26 @@ +# Variables to be inserted into Makefile + +DOMAIN = $(PACKAGE) + +subdir = po +top_builddir = .. + +XGETTEXT_OPTIONS = --add-comments=TRANSLATORS --keyword=_ + +COPYRIGHT_HOLDER = Patrick McDermott + +PACKAGE_GNU = no + +MSGID_BUGS_ADDRESS = mailto:patrick.mcdermott@libiquity.com + +EXTRA_LOCALE_CATEGORIES = + +USE_MSGCTXT = no + +MSGMERGE_OPTIONS = + +MSGINIT_OPTIONS = + +PO_DEPENDS_ON_POT = yes + +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..c1b37bb --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,2 @@ +src/main.c +src/opk.c diff --git a/src/i18n.h b/src/i18n.h new file mode 100644 index 0000000..fbe5186 --- /dev/null +++ b/src/i18n.h @@ -0,0 +1,3 @@ +#include + +#define _(msgid) gettext(msgid) diff --git a/src/local.mk b/src/local.mk index 808322f..e26508f 100644 --- a/src/local.mk +++ b/src/local.mk @@ -2,6 +2,7 @@ opkg_opk_SOURCES += \ %reldir%/defs.h \ %reldir%/gzip.c \ %reldir%/gzip.h \ + %reldir%/i18n.h \ %reldir%/main.c \ %reldir%/opk.c \ %reldir%/opk.h \ -- cgit v0.9.1