Answer the question
In order to leave comments, you need to log in
Internationalization in Widget. How to output a message?
I make a widget and if class Search extends Widget
I write I \Yii::t('company', 'Поиск...')
get an error:
exception 'yii\base\ErrorException' with message 'syntax error, unexpected '(', expecting ',' or ';''
<?php
namespace app\common\components\widget\search;
use \Yii;
use \yii\base\Widget;
class Search extends Widget
{
public $placeholder = \Yii::t('company', 'Поиск...');
public function init()
{
}
public function run()
{
}
}
Answer the question
In order to leave comments, you need to log in
Any decent IDE will tell you why what you wrote is invalid.
Perhaps in Yii this should not be done in the constructor, but the general idea is this:
<?php
namespace app\common\components\widget\search;
use \Yii;
use \yii\base\Widget;
class Search extends Widget
{
public $placeholder;
public function __construct()
{
$this->placeholder = \Yii::t('company', 'Поиск...');
}
public function init()
{
}
public function run()
{
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question