1

I was trying to make translation in JS files.

I have tried

  • 1
require([
'jquery',
'jquery/ui', 
'mage/translate'
], function($){ 
    $(window).load(function() {
        alert($.mage.__('Your Message'));
    });
});
  • 2
<?php echo __('Create Backup') ?>

But nothing worked. It's working fine for strings added in php code.

  • check this link maybe any one answer solve your issue – Hitesh Oct 26 '18 at 12:43
  • Hi @Hit's I have gone through the link and tried.Nothing helps. – anil Oct 30 '18 at 12:21
  • But as per my link, it should work, maybe you doing something wrong, did you got any errors in console/var/log folder? – Hitesh Oct 30 '18 at 12:24
  • 1
    This should solve your problem, please try magento.stackexchange.com/a/260843/42841 – Pinky_P Feb 7 '19 at 11:23
  • 1
    Thanks for the link @Pinky_P , I'll look,try this and get back to you. – anil Feb 7 '19 at 11:59
2

For me, I understood that flushing the translation cache was not deleting the js-translation.json in pub/static/path/to/appropriate/theme/locale. After deleting, the file was renewed and things where going on.

It is actually what is suggested in the comment @Pinky_P made but was hidden to me :(.

| improve this answer | |
  • thank you for that! it's a fix! – zekia Feb 28 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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