Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15

Re: [RFC/PATCH] i18n of multi-line messages

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:52:41

Possibly related (same subject, not in this thread)

On Thu, Dec 22, 2011 at 08:38, Junio C Hamano [off-list ref] wrote:

[Re-formatted for clarity]
-       vreportf("hint: ", advice, params);
+       vreportf("hint", advice, params);
-               vreportf("fatal: ", err, params);
+               vreportf("fatal", err, params);
-       vwritef(child_err, "fatal: ", err, params);
+       vwritef(child_err, "fatal", err, params);
-       vreportf("usage: ", err, params);
+       vreportf("usage", err, params);
-       vreportf("fatal: ", err, params);
+       vreportf("fatal", err, params);
-       vreportf("error: ", err, params);
+       vreportf("error", err, params);
-       vreportf("warning: ", warn, params);
+       vreportf("warning", warn, params);
If we do it like this these would have to have something like:

    vreportf(N_("warning"), warn, params);

Followed by...:
+       strbuf_vaddf(&buf, fmt, params);
+       for (cp = buf.buf; *cp; cp = np) {
+               np = strchrnul(cp, '\n');
+               /*
+                * TRANSLATORS: the format is designed so that in RTL
+                * languages you could reorder and put the "prefix" at
+                * the end instead of the beginning of a line if you
+                * wanted to.
+                */
+               strbuf_addf(&line,
+                           _("%s: %.*s\n"),
+                           prefix,
Changing this to _(prefix).
+                           (int)(np - cp), cp);
+               emit(&line, cb_data);
+               strbuf_reset(&line);
+               if (*np)
+                       np++;
+       }
+       strbuf_release(&buf);
+       strbuf_release(&line);
But ideally to make things clear to the translators it's better to
give them something like this to translate:

    error: %s
    message

Instead of just, as two separate things:

    error
    message

Because:

 1. We might use "error", "warning", "usage" etc. somewhere else, and
    unless we start using the msgctxt feature of gettext we can't
    distinguish between these.

 2. If you present them as two separate things the translator is
    likely to get the case wrong (e.g. translate "error" in the
    nominative case instead of say accusative).

But it's not a big deal, the patch looks good to me as-is with those
N_() and _() changes. Just something to keep in mind.

We can always fixed issues like the one I'm raising later as they crop up.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help