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.

6
  • check this link maybe any one answer solve your issue
    – Hitesh
    Commented Oct 26, 2018 at 12:43
  • Hi @Hit's I have gone through the link and tried.Nothing helps.
    – anil
    Commented Oct 30, 2018 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
    Commented Oct 30, 2018 at 12:24
  • 1
    This should solve your problem, please try magento.stackexchange.com/a/260843/42841
    – Pinky_P
    Commented Feb 7, 2019 at 11:23
  • 1
    Thanks for the link @Pinky_P , I'll look,try this and get back to you.
    – anil
    Commented Feb 7, 2019 at 11:59

1 Answer 1

3

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 :(.

1
  • thank you for that! it's a fix!
    – zekia
    Commented Feb 28, 2020 at 14:05

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.