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

Request #10830 *.gettext.serial string extraction not complete
Submitted: 2007-04-24 18:45 UTC
From: panamajo Assigned: alan_k
Status: Assigned Package: HTML_Template_Flexy (version 1.2.5)
PHP Version: 5.2.1 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2007-04-24 18:45 UTC] panamajo (Jo Schulze)
Description: ------------ The strings extracted to $templatename.gettext.serial lack some strings. AFAICS the only HTML attribute strings unconditionally extracted are (in $PEAR/HTML/Template/Flexy/Compiler/Flexy.php): <img /> alt attributes <a /> title attributes As title is a possible attribute to every HTML tag (except base, basefont, head, html, meta, param, script, style, title) its value should be extracted unconditionally. The alt attribute is considered possible for HTML tag which reference images. That would include eg. <input type="image" /> Most important, for HTML tag input and attribute type submit|reset|button and for HTML tag button and type button, the value attribute strings should be extracted if no further handling via HTML_Template_Flexy_Element is to be expected (when options contain flexyIgnore != FALSE). My patch to $PEAR/HTML/Template/Flexy/Compiler/Flexy.php, method toStringTag(): function toStringTag($element) { $original = $element->getAttribute('ALT'); if (($element->tag == 'IMG') && is_string($original) && strlen($original)) { $this->addStringToGettext($original); $quote = $element->ucAttributes['ALT']{0}; $element->ucAttributes['ALT'] = $quote . $this->translateString($original). $quote; } $original = $element->getAttribute('TITLE'); $this->addStringToGettext($original); $quote = $element->ucAttributes['TITLE']{0}; $element->ucAttributes['TITLE'] = $quote . $this->translateString($original). $quote; $original = $element->getAttribute('VALUE'); if (($element->tag == 'INPUT') && is_string($original) && strlen($original)) { if (in_array(strtoupper($element->getAttribute('TYPE')), array('SUBMIT','BUTTON','INPUT',''))) { $this->addStringToGettext($original); $quote = $element->ucAttributes['VALUE']{0}; $element->ucAttributes['VALUE'] = $quote . $this->translateString($original). $quote; } } Test script: --------------- I used the following template: <table flexy:start="here" width="100%" border="0" cellspacing="0" cellpadding="20"> <tr> <td> <form action="{SERVER[PHP_SELF]}" method="post" name="volvox_login"> <table border="0" cellspacing="0" cellpadding="2" class="linien" align="center"> <thead> <tr> <th align="center" colspan="2">Please login</th> </tr> </thead> <tfoot> </tfoot> <tbody> <tr> <td valign="top" colspan="2"> </td> </tr> <tr> <td valign="top">User:</td> <td valign="top"><input type="text" name="login_name" size="20" maxlength="128" value="{REQUEST[login_name]}" /></td> </tr> <tr> <td valign="top">Password:</td> <td valign="top"><input type="password" name="login_pass" size="20" maxlength="128" value="" /> </td> </tr> <tr> <td align="center" colspan="2"> <br /> <input type="submit" name="submit" class="button" value="Login" > <input type="hidden" name="form_submitted" value="-1" /> <input type="hidden" name="action" value="login" /> </td> </tr> </tbody> </table> </form> </td> </tr> </table> Expected result: ---------------- $c = file_get_contents("./volvox_login.html.gettext.serial"); $out = unserialize($c); print_r($out); Array ( [0] => Please login [1] => User: [2] => Password: [3] => Login ) Actual result: -------------- Array ( [0] => Please login [1] => User: [2] => Password: )

Comments

 [2007-10-18 03:33 UTC] alan_k (Alan Knowles)
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.
 [2008-02-17 12:40 UTC] panamajo (Jo Schulze)
With HTML_Template_Flexy 1.3.2 the alt and title attributes are extracted correctly. But the issue with e.g. <input type="submit" value="this text will be displayed and should be translated" /> still exists.
 [2009-03-08 18:59 UTC] ranvis (Kentaro Sato)
appears added to gettext.serial but not translated? will attach fix and also translate - un"name"ed inputs of type submit/reset/button - area-alt; option,optgroup-label; table-summary; th,td-abbr, object-standby
 [2009-03-08 19:00 UTC] ranvis (Kentaro Sato)
The following patch has been added/updated: Patch Name: gettext.diff URL: patch gettext.diff
 [2009-03-08 19:03 UTC] ranvis (Kentaro Sato)
The following patch has been added/updated: Patch Name: test_gettext.html.phpt URL: patch test_gettext.html.phpt
 [2009-03-08 19:13 UTC] ranvis (Kentaro Sato)
The following patch has been added/updated: Patch Name: gettext.html URL: patch gettext.html