Hi, I posted about this on the General Discussion, but I guess this is a bug, or it could cause bugs if one doesn't pay attention. From the helloworld demo:
<?php
class SiteController extends CController
{
public function actionIndex()
{
$world = 'World Series';
echo Yii::t('demo', 'Hello world', array('world'=>$world));
}
}
Output:
[tt]Hello World Series[/tt]
This could be solved using this modified [tt]YiiBase::t[/tt] method:
<?php
public static function t($category,$message,$params=array())
{
if(self::$_app!==null)
{
$source=$category==='yii'?self::$_app->getCoreMessages():self::$_app->getMessages();
if($source!==null)
$message=$source->translate($category,$message);
}
if (is_array($params) && $params !== array()) {
foreach ($params as $key => $val) {
$message = str_replace('{' . $key . '}', $val, $message);
}
}
return $message;
}
with the benefit that you dont need to surround the key with [tt]{ }[/tt] in the params array, making it nicer. I don't think the performance impact would be so high.