After a few months of trying yii im finally getting confortable with it, but im having a very basic problem, or at least I think so…
I know i can use the Yii::t function through my application to translate strings and labels, but for some reason I cant seem to make it work with the CMenu component.
this is what Im trying to do:
public $menu=array(
array('label' => Yii::t('Option A'), 'url' => array('/optiona')),
);
First of all, Is it even possible to pass a translated string to my CMenu item label ?
Everytime I try to do this i get a syntaxis error.
I feel I’m missing something very basic here. Any help would be much appreciated.
Thanks your your reply, You were right. I was missing the script file with the translated strings.
I was also setting my $items array inside my controller, but i changed it to my view file. Do you know if the Yii:t() function can only be called from a view file?, because if i try to translate my menu items from within my controller i get the syntaxis error. But if I do it from my view everything works as expected.
The reason i try to define my menu items inside the controller is to only declare it once and possibly use it in several views.
It seems i have an error on my end when I try to translate CMenu items on my controller… but I solved what I was trying to accomplish declaring my items array inside a partial view, so now i can reuse the same menu through many views.