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

Request #5773 Decorator - Lang - append keys when fallback lang contains more than current
Submitted: 2005-10-25 06:44 UTC
From: ajt Assigned: quipo
Status: Closed Package: Translation2
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2005-10-25 06:44 UTC] ajt
Description: ------------ This is a patch to provide the Translation2 Fallback Language Decorator with the ability to add missing key when the fallback language contains more entries than the current language. Index: Lang.php =================================================================== RCS file: Translation2/Decorator/Lang.php,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Lang.php --- Lang.php 17 Sep 2005 02:09:55 -0000 1.1.1.1 +++ Lang.php 25 Oct 2005 06:37:26 -0000 @@ -102,13 +102,21 @@ * @param string $langID * @return array */ - function getPage($pageID=TRANSLATION2_DEFAULT_PAGEID, $langID=null, $defaultText='') + function getPage($pageID=TRANSLATION2_DEFAULT_PAGEID, $langID=null, $defaultText='', $appendKeys=false) { $data1 = $this->translation2->getPage($pageID, $langID); $data2 = $this->translation2->getPage($pageID, $this->fallbackLang); - foreach ($data1 as $key => $val) { - if (empty($val)) { - $data1[$key] = $data2[$key]; + $appendKeysClause = ($appendKeys) ? $data2 : $data1; + + foreach ($appendKeysClause as $key => $val) { + if ($appendKeys) { + if (empty($data1[$key])) { + $data1[$key] = $data2[$key]; + } + } else { + if (empty($val)) { + $data1[$key] = $data2[$key]; + } } } return $data1;

Comments

 [2005-10-25 11:59 UTC] quipo
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. -- Hi, I've committed a short fix for this issue. Remember that you can't change method signatures for decorated objects...