+2007-09-02 Bruno Haible <bruno@clisp.org>
+
+ Implement msgctxt for C# ResourceManagers.
+ * intl.cs (GettextResourceManager): New methods GetParticularString,
+ GetParticularPluralString.
+
2006-11-27 Bruno Haible <bruno@clisp.org>
* gettext-0.16.1 released.
+2007-09-02 Bruno Haible <bruno@clisp.org>
+
+ Implement msgctxt for C# ResourceManagers.
+ * x-csharp.c (init_keywords): Also register GetParticularString and
+ GetParticularPluralString.
+ (init_flag_table_csharp): Update accordingly.
+ * write-csharp.c: Include xmalloca.h.
+ (write_csharp_msgid): New function.
+ (write_csharp_code): Use it instead of write_csharp_string.
+ (msgdomain_write_csharp): Remove error message if mlp has entries with
+ context.
+ * msgunfmt.cs (DumpResource.DumpMessage): Emit an msgctxt line
+ if the message contain the context separator.
+
2007-09-01 Bruno Haible <bruno@clisp.org>
Implement msgctxt for Java ResourceBundles.
/* GNU gettext for C#
- * Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ * Copyright (C) 2003-2004, 2007 Free Software Foundation, Inc.
* Written by Bruno Haible <bruno@clisp.org>, 2003.
*
* This program is free software; you can redistribute it and/or modify
Out.Write('"');
}
private void DumpMessage (String msgid, String msgid_plural, Object msgstr) {
+ int separatorPos = msgid.IndexOf('\u0004');
+ if (separatorPos >= 0) {
+ String msgctxt = msgid.Substring(0,separatorPos);
+ msgid = msgid.Substring(separatorPos+1);
+ Out.Write("msgctxt "); DumpString(msgctxt);
+ }
Out.Write("msgid "); DumpString(msgid); Out.Write('\n');
if (msgid_plural != null) {
Out.Write("msgid_plural "); DumpString(msgid_plural); Out.Write('\n');
#include "plural-exp.h"
#include "po-charset.h"
#include "xalloc.h"
+#include "xmalloca.h"
#include "filename.h"
#include "fwriteerror.h"
#include "clean-temp.h"
}
+/* Write a (msgctxt, msgid) pair as a string in C# Unicode notation to the
+ given stream. */
+static void
+write_csharp_msgid (FILE *stream, message_ty *mp)
+{
+ const char *msgctxt = mp->msgctxt;
+ const char *msgid = mp->msgid;
+
+ if (msgctxt == NULL)
+ write_csharp_string (stream, msgid);
+ else
+ {
+ size_t msgctxt_len = strlen (msgctxt);
+ size_t msgid_len = strlen (msgid);
+ size_t combined_len = msgctxt_len + 1 + msgid_len;
+ char *combined;
+
+ combined = (char *) xmalloca (combined_len);
+ memcpy (combined, msgctxt, msgctxt_len);
+ combined[msgctxt_len] = MSGCTXT_SEPARATOR;
+ memcpy (combined + msgctxt_len + 1, msgid, msgid_len + 1);
+
+ write_csharp_string (stream, combined);
+
+ freea (combined);
+ }
+}
+
+
/* Write C# code that returns the value for a message. If the message
has plural forms, it is an expression of type System.String[], otherwise it
is an expression of type System.String. */
for (j = 0; j < mlp->nitems; j++)
{
fprintf (stream, " t.Add(");
- write_csharp_string (stream, mlp->item[j]->msgid);
+ write_csharp_msgid (stream, mlp->item[j]);
fprintf (stream, ",");
write_csharp_msgstr (stream, mlp->item[j]);
fprintf (stream, ");\n");
if (mlp->item[j]->msgid_plural != NULL)
{
fprintf (stream, " t.Add(");
- write_csharp_string (stream, mlp->item[j]->msgid);
+ write_csharp_msgid (stream, mlp->item[j]);
fprintf (stream, ",");
write_csharp_string (stream, mlp->item[j]->msgid_plural);
fprintf (stream, ");\n");
if (mlp->nitems == 0)
return 0;
- /* Determine whether mlp has entries with context. */
- {
- bool has_context;
- size_t j;
-
- has_context = false;
- for (j = 0; j < mlp->nitems; j++)
- if (mlp->item[j]->msgctxt != NULL)
- has_context = true;
- if (has_context)
- {
- multiline_error (xstrdup (""),
- xstrdup (_("\
-message catalog has context dependent translations\n\
-but the C# .dll format doesn't support contexts\n")));
- return 1;
- }
- }
-
retval = 1;
/* Convert the messages to Unicode. */
xgettext.texi! */
x_csharp_keyword ("GetString"); /* Resource{Manager,Set}.GetString */
x_csharp_keyword ("GetPluralString:1,2"); /* GettextResource{Manager,Set}.GetPluralString */
+ x_csharp_keyword ("GetParticularString:1c,2"); /* Resource{Manager,Set}.GetParticularString */
+ x_csharp_keyword ("GetParticularPluralString:1c,2,3"); /* Resource{Manager,Set}.GetParticularPluralString */
default_keywords = false;
}
}
xgettext_record_flag ("GetString:1:pass-csharp-format");
xgettext_record_flag ("GetPluralString:1:pass-csharp-format");
xgettext_record_flag ("GetPluralString:2:pass-csharp-format");
+ xgettext_record_flag ("GetParticularString:2:pass-csharp-format");
+ xgettext_record_flag ("GetParticularPluralString:2:pass-csharp-format");
+ xgettext_record_flag ("GetParticularPluralString:3:pass-csharp-format");
xgettext_record_flag ("String.Format:1:csharp-format");
}
+2007-09-02 Bruno Haible <bruno@clisp.org>
+
+ Implement msgctxt for C# ResourceManagers.
+ * xgettext-csharp-7: New file.
+ * msgunfmt-csharp-1: Add a few messages with context.
+ * lang-csharp: Likewise.
+ * Makefile.am (TESTS): Add xgettext-csharp-7.
+
2007-09-01 Bruno Haible <bruno@clisp.org>
Implement msgctxt for Java ResourceBundles.
xgettext-c-16 \
xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \
xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \
+ xgettext-csharp-7 \
xgettext-elisp-1 xgettext-elisp-2 \
xgettext-glade-1 xgettext-glade-2 xgettext-glade-3 \
xgettext-java-1 xgettext-java-2 xgettext-java-3 xgettext-java-4 \
Console.WriteLine(catalog.GetString("'Your command, please?', asked the waiter."));
Console.WriteLine(String.Format(catalog.GetPluralString("a piece of cake","{0} pieces of cake",n), n));
Console.WriteLine(String.Format(catalog.GetString("{0} is replaced by {1}."), "FF", "EUR"));
+ Console.WriteLine(String.Format(catalog.GetParticularPluralString("++","a piece of cake","{0} pieces of cake",n), n));
+ Console.WriteLine(String.Format(catalog.GetParticularString("++","{0} is replaced by {1}."), "FF", "EUR"));
}
}
EOF
#, csharp-format
msgid "{0} is replaced by {1}."
msgstr ""
+
+#, csharp-format
+msgctxt "++"
+msgid "a piece of cake"
+msgid_plural "{0} pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#, csharp-format
+msgctxt "++"
+msgid "{0} is replaced by {1}."
+msgstr ""
EOF
: ${DIFF=diff}
#, csharp-format
msgid "{0} is replaced by {1}."
msgstr "{1} remplace {0}."
+
+# Euphemistic formulation.
+#, csharp-format
+msgctxt "++"
+msgid "a piece of cake"
+msgid_plural "{0} pieces of cake"
+msgstr[0] "un morceau de gateau succulent"
+msgstr[1] "{0} morceaux de gateau succulent"
+
+# Euphemistic formulation.
+#, csharp-format
+msgctxt "++"
+msgid "{0} is replaced by {1}."
+msgstr "Le nouveau {1} remplace le vieux {0}."
EOF
tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
«Votre commande, s'il vous plait», dit le garçon.
2 morceaux de gateau
EUR remplace FF.
+2 morceaux de gateau succulent
+Le nouveau EUR remplace le vieux FF.
EOF
cat <<\EOF > prog.oku
«Votre commande, s'il vous plait», dit le garçon.
2 morceaux de gateau
EUR remplace FF.
+2 morceaux de gateau succulent
+Le nouveau EUR remplace le vieux FF.
EOF
: ${LOCALE_FR=fr_FR}
#, csharp-format
msgid "{0} is replaced by {1}."
msgstr "{1} remplace {0}."
+
+# A proximity measure.
+msgid "Close"
+msgstr "Proche"
+
+# A menu entry.
+msgctxt "File"
+msgid "Close"
+msgstr "Fermer"
EOF
tmpfiles="$tmpfiles fr/prog.resources.dll"
msgid "'Your command, please?', asked the waiter."
msgstr "«Votre commande, s'il vous plait», dit le garçon."
+msgid "Close"
+msgstr "Proche"
+
+msgctxt "File"
+msgid "Close"
+msgstr "Fermer"
+
msgid "a piece of cake"
msgid_plural "{0} pieces of cake"
msgstr[0] "un morceau de gateau"