I came across the same error. My business is a little different, and I'm starting to think that this has something to do with streaming, despite this, since I changed my code.
I have a language bar:
<?php include_once (dirname(__FILE__) . "/resources/config.php"); ?> <div id='language_bar'> <a style="margin-left:50px" href="./index.php?locale=es_ES"> <img src='<?php echo $config['paths']['images']['lang']?>/es_ES.gif'/> </a> <a href="./index.php?locale=en_UK"> <img src='<?php echo $config['paths']['images']['lang']?>/en_UK.gif'/> </a> <a href="./index.php?locale=de_DE"> <img src='<?php echo $config['paths']['images']['lang']?>/de_DE.gif'/> </a> </div>
And the configuration file with:
if (isset($_GET['locale'])) { $locale = $_GET['locale']; setcookie('locale', $locale, time() + 60 * 60 * 24 * 30); } else { if(isset($_COOKIE['locale'])) { error_log('En _COOKIE'); $locale = $_COOKIE['locale']; } else { $locale = $config['localization']['default_locale']; setcookie('locale', $locale, time() + 60 * 60 * 24 * 30); } } putenv("LC_ALL=$locale"); setlocale(LC_ALL, $locale); error_log('setlocale->'.setlocale(LC_ALL, "0")." Env ->". getenv("LC_ALL")); error_log(_("Submit"));
On my main page there are some divs interacting via jQuery and reload in cascade. Sometimes, some of them (randomly) give a string value by default.
by default, it is in Spanish (es_ES), and after a few clicks of the mouse, causing the div to be updated, some lines are printed in English (original line en_UK). And further. If I switch to German (de_DE), after the first update, where I get each line in German, gettext starts returning lines in Spanish and after a while in English.
Please note that I have added debug lines to the php log. They are really interesting:
When everything goes right:
[Thu May 31 00:28:51 2012] [error] [client ::1] setlocale->es_ES Env ->es_ES [Thu May 31 00:28:51 2012] [error] [client ::1] Aplicar, referer: xxxxxxxx/index.php
If this is not the case:
[Thu May 31 00:29:45 2012] [error] [client ::1] setlocale->es_ES Env ->es_ES, referer: xxxxxxxxx/index.php [Thu May 31 00:29:45 2012] [error] [client ::1] Submit, referer: xxxxxxxx/index.php
So, I think the _ () function is not working (I always use an alias). Just in case, I looped 10,000 times over the function, and it gave either 10,000 hits or 10,000 errors in the translation, so it fails for the whole HTTP request or not.
My apologies for the fact that you wrote so much, but I am very grateful for the help sent to me in the right direction. (This error occurs not only @my localhost, but also on my online test server)
¿May have anything to do with the fact that I set the locale for each connection?
My online site:
Linux server8.nixiweb.com 2.6.32-71.29.1.el6.x86_64 # 1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64
My server:
Linux filete 3.2.0-24-generi # 39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 PHP Version 5.3.10-1ubuntu3.1
Please note that both are 64 bits