From: Bruno Haible Date: Mon, 17 Dec 2001 11:39:19 +0000 (+0000) Subject: Enable marking of plural messages as c-format, lisp-format etc. X-Git-Tag: v0.11~185 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28e4f6984b1ea72f0717e871de44de0651516d8f;p=thirdparty%2Fgettext.git Enable marking of plural messages as c-format, lisp-format etc. --- diff --git a/src/ChangeLog b/src/ChangeLog index 5a644eaa0..8de59196a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-12-15 Bruno Haible + + * xgettext.c (remember_a_message_plural): Mark the message as xx-format + if the English plural form has xx format syntax and the singular form + may or may not have xx format syntax. + 2001-12-15 Bruno Haible * format.h (struct formatstring_parser): Add 'equality' and diff --git a/src/xgettext.c b/src/xgettext.c index 3ce6e78af..5a21ccd1d 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -1054,6 +1054,7 @@ remember_a_message_plural (mp, string, pos) char *msgstr1; size_t msgstr1_len; char *msgstr; + size_t i; msgid_plural = string; @@ -1081,6 +1082,29 @@ remember_a_message_plural (mp, string, pos) memcpy (msgstr + mp->msgstr_len, msgstr1, msgstr1_len); mp->msgstr = msgstr; mp->msgstr_len = mp->msgstr_len + msgstr1_len; + + /* If it is not already decided, through programmer comments or + the msgid, whether the msgid is a format string, examine the + msgid_plural. This is a heuristic. */ + for (i = 0; i < NFORMATS; i++) + if (formatstring_parsers[i] == current_formatstring_parser + && (mp->is_format[i] == undecided || mp->is_format[i] == possible)) + { + struct formatstring_parser *parser = formatstring_parsers[i]; + void *descr = parser->parse (mp->msgid_plural); + + if (descr != NULL) + { + /* Same heuristic as in remember_a_message. */ + if (parser->get_number_of_directives (descr) > 0) + mp->is_format[i] = possible; + + parser->free (descr); + } + else + /* msgid_plural is not a valid format string. */ + mp->is_format[i] = impossible; + } } else free (msgid_plural); diff --git a/tests/ChangeLog b/tests/ChangeLog index da58c7ead..61400b379 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,15 @@ +2001-12-15 Bruno Haible + + * plural-1: Adapt for changed xgettext behaviour w.r.t. format strings + in plural forms. + * lang-c: Likewise. + * lang-c++: Likewise. + * lang-objc: Likewise. + * lang-clisp: Likewise. + * lang-java: Likewise. + * lang-ycp: Likewise. + * lang-po: Likewise. + 2001-12-15 Bruno Haible * msgfmt-1: Remove temporary files in case of error. diff --git a/tests/lang-c b/tests/lang-c index 9f56f5a32..bd83d8c0f 100755 --- a/tests/lang-c +++ b/tests/lang-c @@ -59,6 +59,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" @@ -83,6 +84,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-c++ b/tests/lang-c++ index cf2ee8bf8..d456e3141 100755 --- a/tests/lang-c++ +++ b/tests/lang-c++ @@ -60,6 +60,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" @@ -84,6 +85,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-clisp b/tests/lang-clisp index c0fb73a59..c1290f02c 100755 --- a/tests/lang-clisp +++ b/tests/lang-clisp @@ -28,6 +28,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, lisp-format msgid "a piece of cake" msgid_plural "~D pieces of cake" msgstr[0] "" @@ -48,6 +49,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, lisp-format msgid "a piece of cake" msgid_plural "~D pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-java b/tests/lang-java index f9abd65db..b5022ce00 100755 --- a/tests/lang-java +++ b/tests/lang-java @@ -43,6 +43,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, java-format msgid "a piece of cake" msgid_plural "{0,number} pieces of cake" msgstr[0] "" @@ -67,6 +68,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, java-format msgid "a piece of cake" msgid_plural "{0,number} pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-objc b/tests/lang-objc index e798403e0..5c88400ed 100755 --- a/tests/lang-objc +++ b/tests/lang-objc @@ -73,6 +73,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" @@ -97,6 +98,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-po b/tests/lang-po index 32bc28cc4..f5c7ba6ce 100755 --- a/tests/lang-po +++ b/tests/lang-po @@ -12,6 +12,7 @@ cat <<\EOF > prog-in.pot msgid "'Your command, please?', asked the waiter." msgstr "" +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" @@ -42,6 +43,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/lang-ycp b/tests/lang-ycp index d5275bc3e..8dcbc6165 100755 --- a/tests/lang-ycp +++ b/tests/lang-ycp @@ -25,6 +25,7 @@ cat < prog.ok msgid "'Your command, please?', asked the waiter." msgstr "" +#, ycp-format msgid "a piece of cake" msgid_plural "%1 pieces of cake" msgstr[0] "" @@ -49,6 +50,7 @@ msgid "'Your command, please?', asked the waiter." msgstr "«Votre commande, s'il vous plait», dit le garçon." # Les gateaux allemands sont les meilleurs du monde. +#, ycp-format msgid "a piece of cake" msgid_plural "%1 pieces of cake" msgstr[0] "un morceau de gateau" diff --git a/tests/plural-1 b/tests/plural-1 index b08412ee3..355e748ab 100644 --- a/tests/plural-1 +++ b/tests/plural-1 @@ -9,6 +9,7 @@ ${XGETTEXT} -o cake.pot --omit-header --no-location ${top_srcdir}/tests/plural-1 tmpfiles="$tmpfiles cake.ok" cat < cake.ok +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" @@ -21,6 +22,7 @@ ${DIFF} cake.ok cake.pot || exit 1 tmpfiles="$tmpfiles fr.po" cat < fr.po # Les gateaux allemands sont les meilleurs du monde. +#, c-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" @@ -46,7 +48,7 @@ tmpfiles="$tmpfiles fr.po.tmp" ${MSGUNFMT} fr/LC_MESSAGES/cake.mo -o fr.po.tmp tmpfiles="$tmpfiles fr.po.strip" -sed 1d < fr.po > fr.po.strip +sed 1,2d < fr.po > fr.po.strip : ${DIFF=diff} ${DIFF} fr.po.strip fr.po.tmp || exit 1