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.

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
anil
  • 293
  • 4
  • 17

1 Answers1

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