[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bison-Announce] Bison 3.5.90 released [beta]
From: |
Akim Demaille |
Subject: |
Re: [Bison-Announce] Bison 3.5.90 released [beta] |
Date: |
Mon, 20 Apr 2020 08:00:04 +0200 |
Hi Frank,
> Le 19 avr. 2020 à 17:25, Frank Heckenbach <address@hidden> a écrit :
>
>>> it seems I have to define both
>>> YYENABLE_NLS and ENABLE_NLS. The former is mentioned in the manual
>>> (but only in conjunction with autoblah), the latter not at all.
>>>
>>> So if I got it correctly now, this seems to be the minimum required
>>> for i18n, apart from the bindtextdomain call. Is that correct?
>>>
>>> %define parse.error detailed
>>> %{
>>> #define YYENABLE_NLS 1
>>> #define ENABLE_NLS 1
>>> #define N_
>>> static auto _ (const char *s) { return dgettext ("mydomain", s); }
>>> %}
>>
>> I don't think this is the right approach. I think you are trying
>> to exploit the fact that the skeleton is actually already having
>> support to translate its own messages ("syntax error, expected...").
>>
>> Rather I had something like the attachement in mind. I am very
>> afraid about really installing this in the source tree, because I
>> expect tons of portability issues here: the examples are meant to
>> be self-contained, independent of bison's build, so I cannot use
>> the same tricks to be portable.
>>
>> But I agree it would be better to actually demonstrate the whole
>> process in bistromathic. I'll see what I can do.
>
> I'm not sure I follow you here. I think what I do is rather close to
> what you suggest here. Maybe there was some confusion because I
> hadn't mentioned the steps that were unproblematic (or well-known)
> to me already. So for completeness, I had this already (with my own
> domain, of course):
>
>> # include <libintl.h>
>> setlocale (LC_ALL, "");
>> bindtextdomain ("bistromathic", LOCALEDIR);
>
> But don't you also need:
>
> bindtextdomain ("bison-runtime", BISON_LOCALEDIR);
>
> Or is it there already? I can't seem to find it.
You are right, I missed the (obvious) fact that anyway you *should*
be using this.
> Anyway, I had put
> that in my code, and FWIW I didn't need autoblah and m4 to get
> BISON_LOCALEDIR, I just use the following my Makefile:
>
> -DBISON_LOCALEDIR='"$(shell $(BISON) $(BISON_FLAGS) --print-localedir)"'
Yes, that's exactly the right way to do it! Thanks for reminding
me this... I'll have to emphasize this in the I18n section in the
doc.
> So the only thing missing before it worked for me was:
>
> #define YYENABLE_NLS 1
> #define ENABLE_NLS 1
Yes, you are right, you need both.
> I suppose they're normally set by autoblah, so I need to do this
> manually. But maybe I should rather set them on the command-line
> than in the source!?
I would probably keep them close to BISON_LOCALEDIR, so out
of the file, but...
> Anyway, not a big deal,
yes, both are ok.
> though I think it should at least be briefly
> mentioned, unless you argue using gettext without autoblah is a
> non-supported mode of operation (which I've been doing in other
> projects for a long time and it seems to be working well, and
> doesn't require defining ENABLE_NLS).
Well, you may well use another system that gettext for i18n, it is
not mandatory. The point of this stack of macros is to provide
magic _if_ the user wants to use what's already inside the generated
code. But you may well define YY_ yourself, and not use all the
ENABLE_NLS stuff (provided you take care of all the #includes
yourself). That's why what you need to do looks so weird.
So you are in a way "in between": not using the Autotools magic,
but willing to use the machinery inside.
I'm saying it's wrong. It's only that I had not thought about it.
So, yes, what you do is right. Not only is it right, it's also
what I should be doing in bistromathic. I'll have to complete
the doc.
Thanks!
> BTW:
>
>> textdomain ("bistromathic");
>> # define _(Msgid) gettext (Msgid)
>
> This works for an example (or a "main" program), but I think the
> more general approach (as required e.g. in a library containing a
> parser, where the main program might use its own domain) would be
> no "textdomain" call and rather:
>
> #define _(Msgid) dgettext ("bistromathic", Msgid)
Yes, that is correct. But I don't want this example to be a showcase
for gettext, only for Bison :) Most users need to see the simple
case (i18n of programs), for more complex scenarios, they have to
read gettext's manual.
> PS:
>
>> examples: bistromathic: demontrate internationalization
>
> "demonstrate" ;)
Yeah, I already caught that one too :) Thanks!
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Denis Excoffier, 2020/04/18
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Frank Heckenbach, 2020/04/18
- RFC: "end of file" vs. "end of input" (was: Bison 3.5.90 released), Akim Demaille, 2020/04/19
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Akim Demaille, 2020/04/19
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Frank Heckenbach, 2020/04/19
- Re: [Bison-Announce] Bison 3.5.90 released [beta],
Akim Demaille <=
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Frank Heckenbach, 2020/04/20
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Akim Demaille, 2020/04/24
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Frank Heckenbach, 2020/04/24
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Akim Demaille, 2020/04/25
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Frank Heckenbach, 2020/04/29