someVar = <?php echo $this->__("Yes") ?>

seems to not work. Even when I try console.log(<?php echo $this->__("Yes") ?>). Isn't $this->__() supposed to return just string?

I have the translation in the *.csv file and I know it's the correct one, because I work with other translations from that file in the same template.

2 Answers 2


Make sure that in JavaScript your script is still encapsulated in quotations. Try the following code taking note of the semicolon and quotations.

someVar = '<?php echo $this->__("Yes") ?>';

Thanks to @David Manners for the note, it was helpful. Nevertheless, what solved my problem was using this: '<?php echo Mage::helper('module_name')->__("Yes") ?>'.

  • was type $this not the same as the helper that is odd? Commented Jan 14, 2014 at 16:16
  • @DavidManners - I know it's odd, because, as I said in the question, I use $this->__(...) for another translation from the same .csv file, in the same template and it works flawlessly...
    – Syspect
    Commented Jan 15, 2014 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.