Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.4

Bug #8127 '0' isn't an empty string
Submitted: 2006-07-06 08:56 UTC
From: dan dot b at juno dot co dot uk Assigned: quipo
Status: No Feedback Package: Translation2 (version 2.0.0beta9)
PHP Version: 4.3.9 OS: Linux 2.6.16-1.2108_FC4sm
Roadmaps: (Not assigned)    
Subscription  


 [2006-07-06 08:56 UTC] dan dot b at juno dot co dot uk (Dan)
Description: ------------ It you set up a string as the number zero (as you may well need to translate numbers to arabic), doing a get for this string brings back nothing. I'm guessing that the dreaded 'empty()' function is being used to test for blank strings, which the number 0 falls foul of, even though it's not an empty string. Test script: --------------- -- XML file -- <translation2> <languages> <lang id="en"> <name> english </name> <meta> Some meta info here </meta> <error_text> not available </error_text> <encoding> iso-8859-1 </encoding> </lang> <pages> <page key="test"> <string key="zero"> <tr lang="en"> 0 </tr> </string> </page> </pages> </translation2> -- code -- $trans =& Translation2::factory('XML', array('filname' => 'test.xml')); print "[" . $trans->get('zero', 'test') . "]"; Expected result: ---------------- Prints: [0] Actual result: -------------- Prints: []

Comments

 [2006-07-06 09:23 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. this was not an "empty()" string error, but a missing error propagation in getOne() and getPage(). Please fetch the CVS version. You forgot to set the language: $trans->get('zero', 'test', 'en'); or $trans->setLang('en'); $trans->get('zero', 'test');
 [2006-07-24 08:49 UTC] dan dot b at juno dot co dot uk
Sorry to open this one up again, but I've upgraded to Beta10 and the problem still exists.
 [2006-07-24 18:59 UTC] quipo (Lorenzo Alberton)
Did you read my last message? //You forgot to set the language: $trans->get('zero', 'test', 'en'); //or $trans->setLang('en'); $trans->get('zero', 'test'); do you still experience this issue?