bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Introduce-alignment-mechanism-for-error-messages


From: Akim Demaille
Subject: Re: [PATCH] Introduce-alignment-mechanism-for-error-messages
Date: Thu, 17 Sep 2009 09:28:19 +0200


Le 17 sept. 2009 à 09:02, Alex Rozenman a écrit :

Hi Akim,

Hi Alex!

Before I'll proceed, could you please verify that I understand the
'gettext' correctly ?

It's simple if you understand that there are two phases. The first one is static: you need special mark up so that the strings to be translated can be spotted by the tools. They look for _ and _N. The second step is at runtime: the translation must be looked for. Only _ plays this role, _N is a no-op, it's only markup.

For example:

       const char *msg1 = _("symbol not found");
       const char *msg2 = _("in production");
       const char *msg3 = _("before");

Marked for "to be translated", and translated.

       unsigned indent = 0;

complain_at_indent (text_loc, &indent, _("invalid reference: %s"),

marked, and translated.

                           quote (text));
       indent += 4;
       if (midrule_rhs_index)
complain_at_indent (rule->location, &indent, "%s %s %s $%d: %.*s", msg1, msg2, msg3,midrule_rhs_index, len, cp);
       else
         complain_at_indent (rule->location, &indent, "%s %s: %.*s",
                             msg1, msg2, len, cp);

In "complain_at_indent" I don't even need _N, because it is a "pure"
format string;

Yes, from a computer-science point of view. But from a linguistic point of view, this is most probably wrong: you should not expect that the translated sentences will order the groups in the same way. So translators will probably want the format string to be translated too.

But that's too complex for them (most are not programmer), and it might not even suffice to always produce nice translations. That's why I suggest that you de-factor and truly expose the two full format- strings: get rid of msg[123], inline them in the format string.


Another option:

if (midrule_rhs_index)
         complain_at_indent (rule->location, &indent, _("%s %s before
$%d: %.*s"),
                             msg1, msg2, midrule_rhs_index, len, cp);
       else
         complain_at_indent (rule->location, &indent, "%s %s: %.*s",
                             msg1, msg2, len, cp);

(here I expecting that "before" word will be translated as a part of
format string).
Which option is better ?

This is better, but even better is no msg[123] at all.

You'd like to use _N when translation should not happen there. For instance.

const char* strings[] =
{
  _N("foo"),
  _N("bar"),
  _N("baz"),
};
...
fputs (_(strings[i]);

here, _N is the markup (and you cannot call the _() function here, C does not allow it), and _() later does the real translation at runtime.


Another issue: I am getting now an error in 'bison.texinfo' file, on
the following line:

"As far as we know, these limitations \emph{can} be alleviated. All it takes"

When I change \ to @ the error disappears.
Is it a problem with my 'texi' tools, or it's just a typo ?

A typo. I've added the emphasis when I browsed the diff right before pushing it, and I horribly LaTeXified by Texinfo doc :(

Will fix it, thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]