On Mon, Jan 12, 2026 at 10:26:54PM +0100, [email protected] wrote:
> On Mon, Jan 12, 2026 at 06:21:55PM +0000, Gavin Smith wrote:
> >
> > 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.
>
> I tested something similar in Perl on OpenBSD 7.8, and it does not work.
> With LC_MESSAGES it did not work at all, with LC_CTYPE the switch to the
> locale happens, but there is no translation. Here is the code I tested
> (at the beginning of _switch_messages_locale:
Surely it depends on how libintl-perl is implemented. It imitates the C
library gettext in that it doesn't translate strings in the "C" locale.
So we've got to find some way of convincing libintl-perl it is not in
the "C" locale. According to the setlocale man page you posted, it should
be possible to retrieve set locale categories.
There are various checks under tta/maintain/lib/libintl-perl for
'C' or 'POSIX' locales, which check the result of calling
POSIX::setlocale(LC_MESSAGES). E.g. __load_domain in gettext_pp.pm:
sub __load_domain {
my ($domainname, $category, $category_name, $locale) = @_;
# If no locale was selected for the requested locale category,
# l10n is disabled completely. This matches the behavior of GNU
# gettext.
if ($category != LC_MESSAGES) {
# Not supported.
return [];
}
if (!defined $locale && $category != 1729) {
$locale = POSIX::setlocale ($category);
if (!defined $locale || 'C' eq $locale || 'POSIX' eq $locale) {
return [];
}
}
Would it be possible to check the value of POSIX::setlocale(LC_MESSAGES)
on OpenBSD and find if there is any way to set this to a different value?
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.
The "set and retrieved" part of that implies that this should be possible.