[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: guess_category_value(LC_MESSAGES...) on windows
From: |
Bruno Haible |
Subject: |
Re: guess_category_value(LC_MESSAGES...) on windows |
Date: |
Sun, 23 Jul 2023 13:21:09 +0200 |
Jesse Allen wrote:
> setlocale(LC_ALL, ""); /* at program initialization */
> ...
> /* user wants a different locale */
> setlocale(LC_MESSAGES, locale);
> setlocale(LC_CTYPE, locale);
> #ifndef HAVE_LC_MESSAGES
> // Gettext fakes the setlocale for LC_MESSAGES above via a
> // wrapper, set the env var as well since the var is
> // actually used by gettext when setlocale is not possible.
> setenv("LC_MESSAGES", locale, 1);
> #endif
You should better change this
#ifndef HAVE_LC_MESSAGES
to
#if 1
because that setenv() call is necessary on nearly all platforms, not only
on Windows.
> it only queries environment
> variables. It never uses the value that was stored but is available.
This is done for three reasons:
- We don't know the exact format of the return value of setlocale().
(Per-platform consideration could help here.)
- When the program calls setlocale(), the gettext facility is not
informed about the change of the locale.
(This could be done in the setlocale override, though.)
- setlocale() does not report the settings that the user has set in the
Windows control panel.
So, this could be improved in the future. But is not done yet.
Bruno