Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using gettext in App Engine for PHP8

Hi,

Is it possible to use PHP's gettext system in PHP8? It works fine in PHP5.5 and PHP7.4 but in PHP 8.2 or PHP8.3 no text returned.

Obivously something different is required when running PHP8. Does anyone have an example on how it's supposed to be set up?

 

Solved Solved
2 3 504
1 ACCEPTED SOLUTION

It has been resolved. For those wonder, this is the order of calls to setup gettext in PHP8.

// e.g.
// $sLocale = 'sv_SE';
// $sTextDomain = 'sv'';
putenv("LANGUAGE=$sLocale");
putenv("LC_ALL=$sLocale");
setlocale(LC_ALL, $sLocale);
bindtextdomain($sTextDomain, "./Locale");
textdomain($sTextDomain);
bind_textdomain_codeset($sTextDomain, 'UTF-8');

View solution in original post

3 REPLIES 3