message string coding style (was: r13694 - gnucash/trunk/src/report/report-gnome - )

Christian Stimming stimming at tuhh.de
Fri Mar 24 04:15:47 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Chris,

thanks a lot for implementing this. Yet another showstopper bug
squashed! Great.

However, your coding style concerning the message strings caught my eye.
I already told hampton on IRC what the translators think about that, and
I thought I should point out on the mailing list the implications for
the translators, just for future reference. Your code looks like this:

+static gboolean
+remove_old_report(gpointer key, gpointer val, gpointer data)
+{
+    /* ... */
+    gchar *msg, *str = _("Do you want to display '%s'?");
+    gint response;
+
+    name = gnc_report_name(report);
+    msg = g_strdup_printf(str, name);
+    gtk_message_dialog_set_markup(dialog, msg);
+    /* ... */
+}

Let me explain what this means to translators. Translators will see the
string "Do you want to display '%s'?" in the gnucash.pot file. Then,
they will wonder what this mysterious "%s" might be -- is it a verb, is
it a number, is it the name of a picture, is it the name of whatever? So
the translators will go into the source code file at the line number
that is noted in the gnucash.pot file (pressing "s" in emacs po-mode).
However, since you defined the string *not* inside the actual printf
statement, it is now not at all obvious what the argument to the "%s"
will be. The translator is forced to read through the whole function,
looking for the place where this obnoxious "str" variable is used
eventually. From a translator point of view this sucks. Royally. Please
do *not* use this coding style.

Instead, please use message strings always exactly in the function where
it is used. Especially printf strings. But all others just as well.
Especially because there's not at all any technical reason not to do so.
That is why I emphasize the strong translator's reason: The translators
need to see the exact context of the translation strings, and the easier
this is, the better the translation will be. So please use dialog
strings directly inside the printf and/or gtk_message_dialog_new() et al
function. Thanks a lot.

Christian

Chris Shoemaker schrieb:
> Author: chris
> Date: 2006-03-23 21:01:18 -0500 (Thu, 23 Mar 2006)
> New Revision: 13694
> Trac: http://svn.gnucash.org/trac/changeset/13694
> 
> Modified:
>    gnucash/trunk/src/report/report-gnome/window-report.c
> Log:
>    When opening GnuCash for the first time since 1.8.x, allow the user to 
>    choose which reports (if any) to open.  If the user cancels the dialog,
>    no reports are opened, otherwise, for each report, they are asked whether
>    or not they want to open it.  However, if there are less than 4 reports
>    the dialog is skipped and the reports are just opened.  Closes bug#335188.
> 
>    Note: if someone implements a solution that opened only precisely the
>    reports that were left open in 1.8.x, it's fine to remove this extra code.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRCO4w2XAi+BfhivFAQKAsgP7BZSlhRn4shv3RWR2wre/cR1UrNWt27ia
QcKpj5BlJDixSkEZS2Sos/LCW+2ic8pN+T3SMZ91aiUOwMKwnPsW3VRFOp4Fa943
v1DMKZfRlrjJcJr6N6iNKxQXuvuldhIxdWghKlSbYGo0nVJYrqiMYOVwKrYgLkDH
fd7dc/lU7cM=
=z1cB
-----END PGP SIGNATURE-----


More information about the gnucash-devel mailing list