AM_GNU_GETTEXT
GP_GETTEXT_FLAGS
-AC_DEFINE_UNQUOTED([LIBEXIF_LOCALEDIR],["${datadir}/locale"],
- [The locale directory used with libexif translations])
-AC_DEFINE_UNQUOTED([LIBMNOTE_LOCALEDIR],["${datadir}/locale"],
- [The locale directory used with libexif translations])
+AM_CFLAGS="$AM_CFLAGS -DLIBEXIF_LOCALEDIR=\\\"\$(datadir)/locale\\\""
+AM_CFLAGS="$AM_CFLAGS -DLIBMNOTE_LOCALEDIR=\\\"\$(datadir)/locale\\\""
dnl ---------------------------------------------------------------------------
libexif/pentax/Makefile
libjpeg/Makefile
test/Makefile
+ test/nls/Makefile
m4/Makefile
libexif/libexif.pc
])
libexif/olympus/mnote-olympus-entry.c
libexif/pentax/mnote-pentax-tag.c
libexif/pentax/mnote-pentax-entry.c
+test/nls/test-nls.c
+SUBDIRS = nls
+
noinst_PROGRAMS = test-mem test-tree test-mnote test-value
test_tree_LDADD = $(top_builddir)/libjpeg/libjpeg.la $(top_builddir)/libexif/libexif.la $(INTLLIBS)
--- /dev/null
+nlstestscripts = check-nls.sh
+
+TESTS = $(nlstestscripts)
+
+check_SCRIPTS = $(nlstestscripts)
+
+check_PROGRAMS = test-nls print-localedir
+
+CLEANFILES = $(check_SCRIPTS)
+
+test_nls_LDADD = $(top_builddir)/libexif/libexif.la $(INTLLIBS)
+
+%.sh: %.in Makefile
+ sed 's|@top_builddir\@|$(top_builddir)|g;s|@localedir\@|$(localedir)|g' < $< > $@
+ chmod +x $@
--- /dev/null
+#!/bin/sh
+
+top_builddir="@top_builddir@"
+localedir="@localedir@"
+
+destdir="$(pwd)/tmp-root"
+
+if test -d "${top_builddir}"; then :; else
+ echo "top_builddir \`${top_builddir}' not found"
+ exit 3
+fi
+
+echo -n "Test installation of translated messages..."
+if (cd "${top_builddir}/po" && make DESTDIR="${destdir}" install > /dev/null 2>&1); then
+ echo " done."
+else
+ echo " FAILED."
+ echo "Could not create test installation of translated messages"
+ exit 2
+fi
+
+binlocaledir="$(./print-localedir)"
+mylocaledir="${destdir}${binlocaledir}"
+if test -d "${destdir}${binlocaledir}"; then
+ echo "Test installation contains localedir \`${binlocaledir}'."
+else
+ echo "localedir \`${binlocaledir}' does not exist"
+ exit 1
+fi
+
+testnls="./test-nls ${mylocaledir}"
+if ${testnls}; then
+ echo "NLS test successful"
+ rm -rf "${destdir}"
+ exit 0
+else
+ echo "NLS test failed, not removing test installation from"
+ echo " ${destdir}"
+ exit 1
+fi
--- /dev/null
+#include "config.h"
+#include "i18n.h"
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ puts(LIBEXIF_LOCALEDIR);
+ puts("\n");
+ return 0;
+}
--- /dev/null
+#include "config.h"
+
+#include "i18n.h"
+#include <locale.h>
+
+#include <stdio.h>
+#include <string.h>
+
+struct _testcase {
+ char *locale;
+ char *untranslated;
+ char *expected;
+};
+
+typedef struct _testcase testcase;
+
+static testcase testcases[] = {
+ { "C",
+ "[DO_NOT_TRANSLATE_THIS_MARKER]",
+ "[DO_NOT_TRANSLATE_THIS_MARKER]" },
+ { "de",
+ "[DO_NOT_TRANSLATE_THIS_MARKER]",
+ "[DO_NOT_TRANSLATE_THIS_MARKER_de]" },
+};
+
+int main(int argc, char *argv[])
+{
+ char *localedir;
+ int i;
+
+ if (argc != 2) {
+ puts("Syntax: test-nls <localedir>\n");
+ return 1;
+ }
+
+ localedir = argv[1];
+
+ for (i=0; i < sizeof(testcases)/sizeof(testcases[0]); i++) {
+ char *locale = testcases[i].locale;
+ char *untranslated = testcases[i].untranslated;
+ char *expected = testcases[i].expected;
+ char *translation;
+ char *actual_locale;
+
+ printf("setlocale to %s\n", locale);
+ actual_locale = setlocale(LC_MESSAGES, locale);
+
+ if (actual_locale == NULL) {
+ fprintf(stderr, "Error: Cannot set locale to %s.\n", locale);
+ exit(4);
+ }
+
+ printf("locale is now %s\n", actual_locale);
+
+ puts("before translation");
+ translation = dgettext(GETTEXT_PACKAGE, untranslated);
+ puts("after translation");
+
+ if (strcmp(expected, translation) != 0) {
+ fprintf(stderr, "# %s\n", N_("[DO_NOT_TRANSLATE_THIS_MARKER]"));
+
+ fprintf(stderr,
+ "locale: %s\n"
+ "localedir: %s\n"
+ "untranslated: %s\n"
+ "expected: %s\n"
+ "translation: %s\n"
+ "Error: translation != expected\n",
+ locale,
+ localedir,
+ untranslated,
+ expected,
+ translation);
+
+ return 1;
+ }
+ }
+ return 0;
+}