I have the following code:
<?php
$this->widget('zii.widgets.jui.CJuiButton',array(
'name'=>'save',
'caption'=>Yii::t('app', 'Save'),
'htmlOptions'=>array(
'style'=>'
background: #EA7500;
color: white;',
),
'onclick'=>new CJavaScriptExpression(
'function(){
swal("Saved",
"Successfully saved",
"success");
saveInputFunction();
return false;
}'
),
)); ?>
I want to translate "Saved" and "Successfully saved" using Yii::t("app", "Saved"), however I'm not finding the correct syntax.
I called a js function in 'onclick' parameter and sent the translated message via ajax using an action that I wrote in the controller.
<?php
$this->widget('zii.widgets.jui.CJuiButton',array(
'name'=>'save',
'caption'=>Yii::t('app', 'Save'),
'htmlOptions'=>array(
'style'=>'
background: #EA7500;
color: white;',
),
'onclick'=>'js:function(){
updateInput();
return false;
}',
));
?>
<script>
function updateInput(){
//code
}
</script>