PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » Translation2 » Bug #5539

DefaultText decorator does not call _replaceParams

Details

Submitted2005-09-27 20:50 UTC
Fromjrossiter at pheedo dot com
Assignedquipo
StatusClosed
PackageTranslation2
PHP VersionIrrelevant
OSLinux RHEL3
Roadmaps(Not assigned)

Comments

[2005-09-27 20:50 UTC] jrossiter at pheedo dot com

Description:
------------
The DefaultText decorator does not call _replaceParams on the string before returning it to the user.

Test script:
---------------
(Extraneous details such as language left out)

$tr = Translation2::factory($driver, $dbinfo, $params);
$tr =& $tr->getDecorator('DefaultText');
$tr->setParams(array('foo' => 'bar'));
$output = $tr->get('String &&foo&& not in DB');

Fix:

Simply wrap the return for Translation2_Decorator_DefaultText::get() with $this->_replaceParams()

===================================================================
--- Translation2/Decorator/DefaultText.php
+++ Translation2/Decorator/DefaultText.php
@@ -125,7 +125,7 @@
urlencode($pageID),
$this->url
);
- return $this->emptyPrefix.str_replace($search, $replace, $this->outputString).$this->emptyPostfix;
+ return $this->_replaceParams($this->emptyPrefix.str_replace($search, $replace, $this->outputString).$this->emptyPostfix);
//$str = (empty($defaultText) ? $this->emptyPrefix.$stringID.$this->emptyPostfix : $defaultText);
}

Expected result:
----------------
Output should be "String bar not in DB"

Actual result:
--------------
Actual output is "String &&foo&& not in DB"

[2005-09-27 20:56 UTC] jrossiter at pheedo dot com

This also needs to occur for the defaultText condition inside Translation2_Decorator_DefaultText::get().

if (!empty($defaultText)) {
return $defaultText;
}

should be

if (!empty($defaultText)) {
return $this->_replaceParams($defaultText);
}