Newerton:
Edson,
Sobre os label eu uso direto no model.
public function attributeLabels() {
return array(
'nome' => Yii::t('admin', 'Name'),
);
}
Sobre os erros de mensagem eu iniciei uma vez um wiki(não me lembro agora), que usava sessão, era mais ou menos assim que eu viz no init() do components/Controller.php
if (isset($_POST['_lang'])) {
$app->language = $_POST['_lang'];
$app->session['_lang'] = $app->language;
} else if (isset($app->session['_lang'])) {
$app->language = $app->session['_lang'];
}
Estou tentando fazer o que esta neste topico
http://www.yiiframework.com/wiki/26/setting-and-maintaining-the-language-in-application-i18n
EEsta retornando o erro abaixo:
[b]PHP Error
Descrição
[/b]
[i][i]Missing argument 1 for CController::run(), called in D:\websites\bovimex\framework\web\CBaseController.php on line 166 and defined
Arquivo Fonte[/i][/i]
D:\websites\bovimex\framework\web\CController.php(249)
00237: return array();
00238: }
00239:
00240: /**
00241: * Runs the named action.
00242: * Filters specified via {@link filters()} will be applied.
00243: * @param string action ID
00244: * @throws CHttpException if the action does not exist or the action name is not proper.
00245: * @see filters
00246: * @see createAction
00247: * @see runAction
00248: */
00249: public function run($actionID)
00250: {
00251: if(($action=$this->createAction($actionID))!==null)
00252: {
00253: if(($parent=$this->getModule())===null)
00254: $parent=Yii::app();
00255: if($parent->beforeControllerAction($this,$action))
00256: {
00257: $this->runActionWithFilters($action,$this->filters());
00258: $parent->afterControllerAction($this,$action);
00259: }
00260: }
00261: else
O que estou fazendo de errado?
meu codigo:
components/Idioma.php
<?php
class Idioma extends CController
{
function init()
{
parent::init();
$app = Yii::app();
if (isset($_POST['_lang']))
{
$app->language = $_POST['_lang'];
$app->session['_lang'] = $app->language;
}
else if (isset($app->session['_lang']))
{
$app->language = $app->session['_lang'];
}
}
}
?>
components/Linguagem.php
<?php
class Linguagem extends CWidget
{
public function run()
{
$currentLang = Yii::app()->language;
$this->render('linguagemBox', array('currentLang' => $currentLang));
}
}
?>
components/views/linguagemBox.php
<?php echo CHtml::form(); ?>
<div id="langdrop">
<?php echo CHtml::dropDownList('_lang', $currentLang, array(
'en' => 'English', 'pt' => 'Teste'), array('submit' => '')); ?>
</div>
<?php echo CHtml::endForm(); ?>
Nao sei se tem que setar alguma coisa no main.php pois a unica coisa que tem é:
‘language’=>‘pt’,