]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Add test for last fix.
authorBruno Haible <bruno@clisp.org>
Sun, 26 Jun 2022 07:05:16 +0000 (09:05 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2022 07:30:42 +0000 (09:30 +0200)
Reported by Jonathan Matthew <jonathan@d14n.org>
in <https://savannah.gnu.org/bugs/?62363>.

* gettext-tools/tests/xgettext-18: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-18 [new file with mode: 0755]

index 5e13775942fbf75fb9a5caead0c93685983f34f4..9a7ae03dea1d7346f90e1de92fddc98320fecf7f 100644 (file)
@@ -1,5 +1,5 @@
 ## Makefile for the gettext-tools/tests subdirectory of GNU gettext
-## Copyright (C) 1995-1997, 2001-2010, 2012-2016, 2018-2020 Free Software Foundation, Inc.
+## Copyright (C) 1995-1997, 2001-2010, 2012-2016, 2018-2022 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -78,6 +78,7 @@ TESTS = gettext-1 gettext-2 \
        xgettext-2 xgettext-3 xgettext-4 xgettext-5 xgettext-6 \
        xgettext-7 xgettext-8 xgettext-9 xgettext-10 xgettext-11 xgettext-12 \
        xgettext-13 xgettext-14 xgettext-15 xgettext-16 \
+       xgettext-18 \
        xgettext-appdata-1 \
        xgettext-awk-1 xgettext-awk-2 \
        xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 xgettext-c-6 \
diff --git a/gettext-tools/tests/xgettext-18 b/gettext-tools/tests/xgettext-18
new file mode 100755 (executable)
index 0000000..fc22562
--- /dev/null
@@ -0,0 +1,41 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test format string recognition when different programming languages are used.
+
+cat <<\EOF > xg-18-a.py
+print(gettext.gettext("Found %(count)d warnings") % { 'count': 7 })
+EOF
+
+cat <<\EOF > xg-18-b.ui
+<?xml version="1.0"?>
+<interface>
+  <menu id="app-menu">
+    <section>
+      <submenu>
+        <attribute name="label" translatable="yes">Use in % of disk</attribute>
+      </submenu>
+    </section>
+  </menu>
+</interface>
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -d xg-18.tmp xg-18-a.py xg-18-b.ui \
+  || Exit 1
+LC_ALL=C tr -d '\r' < xg-18.tmp.po > xg-18.po || Exit 1
+
+cat <<EOF > xg-18.ok
+#, python-format
+msgid "Found %(count)d warnings"
+msgstr ""
+
+msgid "Use in % of disk"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-18.ok xg-18.po
+result=$?
+
+exit $result