in my case i use translation in magento 2 , all the string text to be translated works fine, but when i want to translate a variable i can't get the translation , can anyone tell me why ?

<?= $block->escapeHtml(__($var->getData()['colomn'])) ?>



translat file

"text","text translate"

why i can't get "text translate" instead of "processing" ?

2 Answers 2


anyway it works for by doing this ,

<?= __($block->escapeHtml($var->getData()['column'])) ?>

You can try the below way to translate the variable.

<?= __($block->escapeHtml($var->getData()['column'])) ?>

Also, please add the module name in your translation file like below.

"processing","En cours de traitement",module,Magento_Sales


"processing","En cours de traitement",module,Magento_Theme

Reference: https://alanstorm.com/magento-2-translation-function-not-sprintf/

Hope this will work for you.

  • thank you for your response but it's not working i don't know why !? Apr 16, 2020 at 9:02
  • Have you cleared the cache after changes? Apr 16, 2020 at 9:03
  • yes and upgrading also Apr 16, 2020 at 9:06
  • anyway it works for by doing this , <?= __($block->escapeHtml($var->getData()['column'])) ?> Apr 16, 2020 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.