I have a problem using translate function.

This works:

$this->__("You can contact %s by calling %s.", $name, $phone);

But this doesn't:

$this->__("You can contact %1$s by calling %2$s.", $name, $phone);

And the problem is, that I would like to translate this as: "Please call %2$s to speak to %1$s." so the order is important.

Do you have any ideas why the second example doesn't work? I would appreciate any suggestions :).

2 Answers 2


Magento uses PHPs vsprintf method. So instead of %1$s you'll have to use %1\$s

  • You're welcome. Glad I could help Dec 11, 2014 at 8:54

I'm propose other method for display multiple variables with magento2.

I use this:

echo __('My name is [%1] and lastname(%2)',$name,$lastname);


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.