bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] [PATCH] xgettext: Wrap location comments to 79 characters


From: Alex Henrie
Subject: [bug-gettext] [PATCH] xgettext: Wrap location comments to 79 characters
Date: Wed, 4 Feb 2015 22:59:14 -0700

Currently, messages are wrapped to 79 characters, but location comments
are wrapped to 78 characters. Besides making slightly better use of
horizontal space, consistent rules for line wrapping will make it easier
to develop alternative PO file generators/editors and make sure that
their output matches gettext's. Qt Linguist, for example, rewraps all
location comments every time you save the PO file, which results in an
unnecessarily large diff because Qt Linguist thinks that all lines
should be wrapped in the same way and gettext currently doesn't.
---
 gettext-tools/src/write-po.c    |   2 +-
 gettext-tools/tests/xgettext-13 | 146 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100755 gettext-tools/tests/xgettext-13

diff --git a/gettext-tools/src/write-po.c b/gettext-tools/src/write-po.c
index d49a95f..701decf 100644
--- a/gettext-tools/src/write-po.c
+++ b/gettext-tools/src/write-po.c
@@ -400,7 +400,7 @@ message_print_comment_filepos (const message_ty *mp, 
ostream_t stream,
               else
                 sprintf (buffer, ":%ld", (long) pp->line_number);
               len = strlen (cp) + strlen (buffer) + 1;
-              if (column > 2 && column + len >= page_width)
+              if (column > 2 && column + len > page_width)
                 {
                   ostream_write_str (stream, "\n#:");
                   column = 2;
diff --git a/gettext-tools/tests/xgettext-13 b/gettext-tools/tests/xgettext-13
new file mode 100755
index 0000000..1d1197f
--- /dev/null
+++ b/gettext-tools/tests/xgettext-13
@@ -0,0 +1,146 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test wrapping long lines
+# Words in messages and location comments should wrap to at most 79 characters
+
+cat <<\EOF > xg-test13.c
+gettext("123456789 123456789 123456789 123456789 123456789 123456789 123456789 
123456 7890");
+gettext("123456789 123456789 123456789 123456789 123456789 123456789 123456789 
1234567 890");
+
+
+
+
+
+
+
+#line 10
+gettext("foo");
+gettext("foo");
+gettext("foo");
+gettext("bar");
+gettext("bar");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 100
+gettext("foo");
+gettext("foo");
+gettext("bar");
+gettext("bar");
+gettext("bar");
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header -d xg-test13.tmp xg-test13.c || exit 1
+LC_ALL=C tr -d '\r' < xg-test13.tmp.po > xg-test13.po || exit 1
+
+cat <<\EOF > xg-test13.ok
+#: xg-test13.c:1
+msgid ""
+"123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 "
+"7890"
+msgstr ""
+
+#: xg-test13.c:2
+msgid ""
+"123456789 123456789 123456789 123456789 123456789 123456789 123456789 "
+"1234567 890"
+msgstr ""
+
+#: xg-test13.c:11 xg-test13.c:12 xg-test13.c:13 xg-test13.c:101 xg-test13.c:102
+msgid "foo"
+msgstr ""
+
+#: xg-test13.c:14 xg-test13.c:15 xg-test13.c:103 xg-test13.c:104
+#: xg-test13.c:105
+msgid "bar"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-test13.ok xg-test13.po
+result=$?
+
+exit $result
-- 
2.2.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]