On Mon, Jan 12, 2026 at 11:40:27PM +0100, Bruno Haible wrote:
> Patrice Dumas wrote:
> > I had a look at the setlocale man page on this platform and there is
> > this paragraph:
> >
> > On OpenBSD, the only useful value for the category is LC_CTYPE. It
> > sets
> > the locale used for character encoding, character classification, and
> > case conversion. For compatibility with natural language support in
> > packages(7), all other categories -- LC_COLLATE, LC_MESSAGES,
> > LC_MONETARY, LC_NUMERIC, and LC_TIME -- can be set and retrieved, too,
> > but their values are ignored by the OpenBSD C library. A category of
> > LC_ALL sets the entire locale generically, which is strongly
> > discouraged
> > for security reasons in portable programs.
> >
> > So, unless I misinterpret this, it seems that LC_CTYPE should be used
> > instead of LC_MESSAGES on that platform.
>
> No, no. You can't take the OpenBSD man page regarding locales seriously
> because the OpenBSD people haven't understood locales:
> * They think that because in different locales, some results are different,
> locales are dangerous and need to be discouraged.
> * While they have a setlocale() that remembers the given value — for the
> packages, as they say, — they have forgotten to implement the same thing
> in uselocale(). Making uselocale() pointless in OpenBSD.
> * setlocale (LC_ALL, value) is equivalent to
> setlocale (LC_CTYPE, value)
> && setlocale (LC_MESSAGES, value)
> && setlocale (LC_NUMERIC, value)
> && ...
> When you set only LC_CTYPE, messages will always come out untranslated,
> i.e. in English.
Note that in the context of Perl code in Texinfo, we do not really care
about the handling of locales in OpenBSD much, as we use the
libintl-perl Perl module as Gavin explained. So it is not an issue if
the messages are untranslated in the OpenBSD C library/libintl, as we do
not use it, but, again as reported by Gavin, we need to have a call,
with $category = LC_MESSAGES that returns something else than 'C' or
'POSIX' in the libintl-perl gettext_pp.pm __load_domain function:
$locale = POSIX::setlocale ($category);
With POSIX::setlocale being (I have not checked the code, but I am
pretty sure about it) a wrapper around the platform C library setlocale
function.
In the equivalent C code in Texinfo, however, we do use the OpenBSD C
library/libintl, but it works with the code below, then setting LANGUAGE
and a call of gettext or pgettext_expr.
> > setenv_status = setenv ("LC_ALL", "en_US.UTF-8", 1)
> > || setenv ("LANG", "en_US.UTF-8", 1);
> > locale = setlocale (LC_MESSAGES, "");
>
> The second of these lines is redundant: If setenv ("LC_ALL", "en_US.UTF-8", 1)
> fails, the only possible reason is out-of-memory, and then it's pointless to
> try the same thing with "LANG".
Ok, thanks, I'll change the code.
--
Pat