is there a way to use gettext and _("xxx") with Yii?
is there a way to use gettext and _("xxx") with Yii?
Try to create your own application component, like:
class CGettext extends CApplicationComponent {
public $source="application.messages";
public $domains=array('myApp');
protected $domain="default";
public function init(){
$lang=Yii::app()->getLanguage();
// Set language
putenv('LC_ALL='.$lang);
setlocale(LC_ALL, $lang);
// Specify location of translation tables
foreach($this->domains as $domain)
bindtextdomain($domain, Yii::getPathOfAlias($this->source));
parent::init();
}
public function setDomain($value){
// Choose domain
textdomain($this->domain=$value);
}
public function getDomain(){
return $this->domain;
}
}