I am making ajax request , and I call __('string to translate') function on backend. The problem is that translate is not working at all. My ajax controller is implementing HttpPostActionInterface Interface to avoid massive data load. If I use previous way, i.e extending \Magento\Framework\App\Action\Action , the translation is working good, however I don't wan't to extend this huge class. Have anybody got idea why HttpPostActionInterface is not working with translations?

I've tried various things, including this here , however nothing seems to be working. I will do translations on frontend side eventually , but this doesn't explain why translations are missed on this interface?

  • Can you describe with code what you have try and where that not working. Commented Jan 15, 2021 at 11:33
  • I am making simple AJAX request and in backend controller I use $response['message'] = __('Translated text'); . The problem is that text is translated if I extend controller with \Magento\Framework\App\Action\Action , however it does not when controller is only implementing HttpPostActionInterface
    – BlueScrinn
    Commented Jan 18, 2021 at 6:21

1 Answer 1


You need to use translate js for this:

], function($){ 
    $.mage.__('Your text message for translation')

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.