I'm using a modal to show conditions for subscribing to a newsletter list. But I'm having trouble translating the title when initializing the modal inside a phtml file.

The modal opens normally, but seems the mage/translate component doesn't successfully translate the title.

If I use title: <?php echo _('Test string') ?> it will translate normally, but shouldn't using $.mage.__('Test string') also work?

This is what I have in phtml:

    ], function ($, modal) {
        var options = {
            type: 'popup',
            modalClass: 'newsletter-conditions-modal',
            responsive: true,
            innerScroll: true,
            title: $.mage.__('Test string'),
            buttons: []
        $(function () {
            $('.newsletter-conditions').on('click',function() {

And this is what I have in my csv translate file:

Test string,Test string 2,module,Magento_Ui

Can anyone tell me why this isn't working?

1 Answer 1


Came here for the same issue. But found out you will need to use php to get it translated.

title: "<?php echo __('Test string')?>"

  • It's not working for me. Commented Mar 7, 2021 at 7:16

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.