I had a task to show the back order message in the mini cart. What I did is just take the message from the customer cart section and show it in the mini cart. Now the problem is with the translation. The message is not translating in the customer section but it is working in cart and checkout page.

enter image description here

What I understood is that the translation only works when content renders in the front end (phtml file). In the cart and checkout page, it is actually rendering on phtml page and that is why it is working. Let me know if anyone can help me with this. Thank you.

1 Answer 1


Is the issue here that you are not getting a translated string in your API response?

The issue here is usually that the translation cannot be found as API requests use webapi_rest theme. When the request comes in, the code is executed and translations are gathered from various sources:

  • Module translation files
  • Theme translation files (most common place for storing translations)
  • DB translations (in translations DB table per locale)

Normal themes load translations from their theme dir app/design/frontend/MyProject/default/i18n - but as webapi_rest isn't a real theme - no translation files.

The fix for this is to define your translation per locale within the module responsible for custom message generation (app/code/Namespace/Module/i18n). When loading translations from API requests, the theme source will still return null - but now the module source will be populated, meaning Magento can find and translate the string.

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.