Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
How can I use Yii 1.1 translation inside a CJavaScriptExpression?

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!