]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Enable marking of plural messages as c-format, lisp-format etc.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Dec 2001 11:39:19 +0000 (11:39 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 21:45:37 +0000 (23:45 +0200)
src/ChangeLog
src/xgettext.c
tests/ChangeLog
tests/lang-c
tests/lang-c++
tests/lang-clisp
tests/lang-java
tests/lang-objc
tests/lang-po
tests/lang-ycp
tests/plural-1

index 5a644eaa0871dc45870fb0bd1c4e85a5152069f0..8de59196a6b702801cf5e29cc31781139a9d08f3 100644 (file)
@@ -1,3 +1,9 @@
+2001-12-15  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * format.h (struct formatstring_parser): Add 'equality' and
index 3ce6e78afa961c82c5a20eaacd5cd478fbdc374f..5a21ccd1d326eeaf3208876d9e1d3801333611ff 100644 (file)
@@ -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);
index da58c7ead6541f1c098feb85b10f1ba0298128f5..61400b379ae4b341d9e16baa5ba2745fae928d02 100644 (file)
@@ -1,3 +1,15 @@
+2001-12-15  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * msgfmt-1: Remove temporary files in case of error.
index 9f56f5a32c799c6659c8baa5fe584b8738f374ea..bd83d8c0fccbdd57ab0546e1062e40a8e3339af2 100755 (executable)
@@ -59,6 +59,7 @@ cat <<EOF > 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"
index cf2ee8bf80de21f660dc34ff39d5f28369be525a..d456e314103bd0e1ad1da0f13a73d434566e3960 100755 (executable)
@@ -60,6 +60,7 @@ cat <<EOF > 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"
index c0fb73a5937b6dbb9d145bf97e4ad66c4af76eb1..c1290f02cf1af18a4be6bd638801c31e9dd55952 100755 (executable)
@@ -28,6 +28,7 @@ cat <<EOF > 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"
index f9abd65dbbb2a6348fb6bc6d8e47af45a7a14b59..b5022ce006ed0c48178cc4b0fa2d8c9c90ad20a6 100755 (executable)
@@ -43,6 +43,7 @@ cat <<EOF > 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"
index e798403e05d046f32567ed190469ac56040669f1..5c88400ed701af66a1dc68a1fb49a4ad696385a0 100755 (executable)
@@ -73,6 +73,7 @@ cat <<EOF > 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"
index 32bc28cc40f2b58edd92b4dd42c5e5dabc71872a..f5c7ba6ce9c6fd3583853d3ba9b9f2a00fd832ad 100755 (executable)
@@ -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"
index d5275bc3e0d78a7a207657c40ebe934742fe0d09..8dcbc616580a444416a44347863f811e9fc819fd 100755 (executable)
@@ -25,6 +25,7 @@ cat <<EOF > 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"
index b08412ee3daf55abb5d65c5d46431a804d75b181..355e748aba81fddc3dc3596f4953a01aa20655a9 100644 (file)
@@ -9,6 +9,7 @@ ${XGETTEXT} -o cake.pot --omit-header --no-location ${top_srcdir}/tests/plural-1
 
 tmpfiles="$tmpfiles cake.ok"
 cat <<EOF > 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 <<EOF > 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