On Mon, Jan 12, 2026 at 06:59:29PM +0200, Eli Zaretskii wrote:
> > > My feeling is that it works in C, because we do it a bit differently,
> > > like:
> > > 
> > >       setenv_status = setenv ("LC_ALL", "en_US.UTF-8", 1)
> > >                       || setenv ("LANG", "en_US.UTF-8", 1);
> > >       locale = setlocale (LC_MESSAGES, "");
> > 
> > I don't know if it's relevant, but MS-Windows' setlocale also doesn't
> > support LC_MESSAGES.
> 
> Also, LC_ALL in the environment doesn't affect the MS-Windows'
> setlocale.
> 
> Why does the code above go via the environment, btw? why not simply
> 
>   locale = setlocale (LC_MESSAGES, "en_US.UTF-8");
> 
> ?

I had the same question:

Bruno Haible wrote on Sun, 01 Dec 2024:
> In other words, instead of doing
>   setlocale (LC_ALL, "en_US.UTF-8");
> you need to do
>   setenv ("LC_ALL", "en_US.UTF-8", 1);
>   setlocale (LC_ALL, "");
> 
> It's unfortunate that your code is working as expected on GNU, FreeBSD, 
> NetBSD,
> Solaris systems but not on macOS, Windows, AIX, and OpenBSD. But there are
> (complicated) reasons for it, see
> https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/localename-unsafe.c;h=0a2654d8a3fcd025c80d4ad6eb34ce02c13879e5;hb=HEAD#l3202

https://lists.gnu.org/archive/html/bug-gettext/2024-11/msg00050.html

I don't understand the reasons but the conclusion seems to be that we
have to use this round-about way of setting the locale, which we've
come to after some amount of trial and error.

    • ... Patrice Dumas
      • ... Gavin Smith
  • Re: ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
    • ... Gavin Smith
      • ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
        • ... Gavin Smith
  • Re: ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
    • ... Patrice Dumas
      • ... Eli Zaretskii
        • ... Eli Zaretskii
          • ... Gavin Smith
            • ... pertusus
              • ... Gavin Smith
          • ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
      • ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
  • Re: ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
  • Re: ... Bruno Haible via Bug reports for the GNU Texinfo documentation system
    • ... Gavin Smith
      • ... Eli Zaretskii
        • ... Patrice Dumas
      • ... Patrice Dumas

Reply via email to