l***@gmail.com
2018-03-08 22:51:44 UTC
Currently localename.c (which is used by gettext, so it's really everywhere)
calls GetThreadLocale() to get current locale identifier (if LC_* or LANG are
not set).
One problem with that is that GetThreadLocale() is unaffected by setlocale()
(already discussed in "Fix libunistring in MS-Windows locales" back in 2014).
Another problem is that GetThreadLocale() defaults like this (according to MSDN):
"When a new thread is created in a process, it inherits the locale of the
creating thread. This locale can be either the default Standards and Formats
locale or a different locale set for the creating thread in a call to
SetThreadLocale"
It was pointed out to me recently that the locale obtained from "Standards and
Formats" (also known as "intl.cpl") is *not* the "UI locale". That is, the
settings from intl.cpl influence the way timestamps, dates, currency and
numbers are displayed. But they do not decide the UI language.
Because of this gettext-using programs tend to pick the wrong default locale
when running on Windows.
I'm currently thinking what to do about this. Maybe GetThreadUILanguage()
instead? OTOH, date, time, number, currency formats and days-of-the-week names
should probably continue to be obtained from intl.cpl (directly or indirectly;
i'm not sure whether C runtime functions do that, but there are W32 APIs for
that, such as GetLocaleInfo(), and i remember seeing them being used in a plibc
nl_langinfo() implementation back in the day; gnulib uses strftime() for this,
and it seems to be working, so that could be expanded too, i guess).
calls GetThreadLocale() to get current locale identifier (if LC_* or LANG are
not set).
One problem with that is that GetThreadLocale() is unaffected by setlocale()
(already discussed in "Fix libunistring in MS-Windows locales" back in 2014).
Another problem is that GetThreadLocale() defaults like this (according to MSDN):
"When a new thread is created in a process, it inherits the locale of the
creating thread. This locale can be either the default Standards and Formats
locale or a different locale set for the creating thread in a call to
SetThreadLocale"
It was pointed out to me recently that the locale obtained from "Standards and
Formats" (also known as "intl.cpl") is *not* the "UI locale". That is, the
settings from intl.cpl influence the way timestamps, dates, currency and
numbers are displayed. But they do not decide the UI language.
Because of this gettext-using programs tend to pick the wrong default locale
when running on Windows.
I'm currently thinking what to do about this. Maybe GetThreadUILanguage()
instead? OTOH, date, time, number, currency formats and days-of-the-week names
should probably continue to be obtained from intl.cpl (directly or indirectly;
i'm not sure whether C runtime functions do that, but there are W32 APIs for
that, such as GetLocaleInfo(), and i remember seeing them being used in a plibc
nl_langinfo() implementation back in the day; gnulib uses strftime() for this,
and it seems to be working, so that could be expanded too, i guess).