Jump to content

PHP Gettext function fails after Update from PHP 7.2 to 8.x


kixe
 Share

Recommended Posts

Loading a website after updating to PHP 8.x failed. The connection to the server was reset while the page was being loaded. NS_ERROR_NET_RESET
PHP error was not catched, nothing displayed, nothing logged. After a long search, it turned out that the Gettext extension was responsible for the fatal error. Code example to reproduce:

$locale = 'de_DE';
setlocale(LC_ALL, $locale);
echo gettext("foo bar");
// NS_ERROR_NET_RESET

After adding the environment variable LANG it worked as expected.

$locale = 'de_DE';
setlocale(LC_ALL, $locale);
putenv("LANG=$locale");
echo gettext("foo bar");
// foo bar

Same behaviour with ngettext() and maybe other Gettext functions.

Alternatively, the problem could also be solved with

putenv("LC_ALL=$locale");

Possibly affected:

ProcessWire\Languages::setLocale()

I found little information about this behavior on the Internet.

  • Like 1
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...