[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bison-Announce] Bison 3.5.90 released [beta]
From: |
Frank Heckenbach |
Subject: |
Re: [Bison-Announce] Bison 3.5.90 released [beta] |
Date: |
Sun, 19 Apr 2020 17:25:32 +0200 |
Akim Demaille wrote:
> I guess it would be ok to just define it if N_ is not yet
> #defined.
I'd appreciate that, one less line of boilerplate. :)
> > 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. 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)"'
So the only thing missing before it worked for me was:
#define YYENABLE_NLS 1
#define ENABLE_NLS 1
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!?
Anyway, not a big deal, 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).
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)
PS:
> examples: bistromathic: demontrate internationalization
"demonstrate" ;)
Regards,
Frank
- 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 <=
- Re: [Bison-Announce] Bison 3.5.90 released [beta], Akim Demaille, 2020/04/20
- 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