note 125516 added to function.gettext

From: Date: Mon, 16 Nov 2020 12:57:05 +0000
Subject: note 125516 added to function.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-215856@lists.php.net to get a copy of this message
If you come across a situation where the translation works fine on CLI but not on Apache, it may be caused by the Perl Apache module. Basic translate.php: <?php // Set locale putenv("LC_ALL=de_CH.UTF-8"); putenv("LANGUAGE="); putenv("LANG=de_CH.UTF-8"); $res = setlocale(LC_ALL, 'de_CH.UTF-8', 'de_CH', 'de'); echo bindtextdomain("homepage", "./locale"); textdomain("homepage"); $results = gettext("My English Text"); if ($results === "My English Text") { echo "Original English was returned. Something wrong\n"; } else { echo $results; } ?> On the CLI the translation works: $ php7.3 translate.php Mein deutscher Text. But not via Apache web server: $ curl localhost/translate.php Original English was returned. Something wrong Disable Perl module and restart Apache: # a2dismod perl # systemctl restart apache2 And suddenly the translation works: $ curl localhost/translate.php Mein deutscher Text. The exact reason for this behaviour is (as of right now) unknown to me. ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.47 (proxied: 84.20.57.136) ---- Manual Page -- http://php.net/manual/en/function.gettext.php Edit -- https://master.php.net/note/edit/125516 Del: integrated -- https://master.php.net/note/delete/125516/integrated Del: useless -- https://master.php.net/note/delete/125516/useless Del: bad code -- https://master.php.net/note/delete/125516/bad+code Del: spam -- https://master.php.net/note/delete/125516/spam Del: non-english -- https://master.php.net/note/delete/125516/non-english Del: in docs -- https://master.php.net/note/delete/125516/in+docs Del: other reasons-- https://master.php.net/note/delete/125516 Reject -- https://master.php.net/note/reject/125516 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215856) next »