Of course it is translatable. I solved it overriding the getPageTitle() and setPageTitle() methods in my own Controller base class like this:
private $_pageTitle;
public function getPageTitle()
{
if($this->_pageTitle!==null) {
return Yii::t('wm', $this->_pageTitle);
} else {
$controller = Yii::t('wm', ucfirst(basename($this->getId())));
if($this->getAction()!==null && strcasecmp($this->getAction()->getId(),$this->defaultAction)) {
$action = Yii::t('wm', ucfirst($this->getAction()->getId()));
return $this->_pageTitle=Yii::app()->name.' - '.Yii::t('wm', '{action} {controller}', array('{action}' => $action, '{controller}' => $controller));
} else {
return $this->_pageTitle=Yii::app()->name.' - '.$controller;
}
}
}
Then, in my translations file de/wm.php, I have, between all translations for the controller IDs and actions, this lines:
return array(
'Comment' => 'Kommentar',
'Create' => 'Erstellen',
'Delete' => 'Löschen',
'Update' => 'Bearbeiten',
'{action} {controller}' => '{controller} {action}', // This is flipped in German: "subject verb"
);
This allows me to translate a automatic guessed page title like ‘Create Comment’ (en) to ‘Kommentar Erstellen’ (de).
For the spanish version it would look like this:
return array(
'Comment' => 'Comentario',
'Create' => 'Crear',
'Delete' => 'Borrar',
'Update' => 'Editar',
'{action} {controller}' => '{action} {controller}', // same syntax as in English: "verb subject"
);
Of course, there are still cases where I have to adjust the page title manually in the controller, but for a lot of typical CRUD operations, this works great.
Regards
Paul.