13

What is Magento 2 trying to avoid by suspending inline translation before it sends and then resuming after?

2 Answers 2

10
+50

Inline translation is disabled when sending an email because, when inline translation is active, any translatable printed text (__('Text here')) goes through Magento\Framework\Phrase\RendererMagento\Framework\Phrase\Renderer\Inline::render

This method adds some markup around the text {{{ and }}} that is used later by some javascript code that interprets them and shows the nice little buttons and popups for inline translation.... but....

This works only if you are on the website in question and that js is loaded.
Since phtml templates can be used in email templates, if inline translation is enabled, you would get the texts in the email like {{{ some text here }}{{ other text here }}} because the special markup will not be interpreted.
So this is a security measure so you don't screw up your email tempaltes

0
3

When in-line translation is allowed public function string will translated accordingly. So you need disable it and resume later.

This also prevent issues with improperly enabled inline translation.

Adding function for suspend inline translation was related with conflicts, please read :

https://github.com/magento/magento2/pull/11320

https://www.absolute-design.co.uk/services/magento-ecommerce/how-can-i-fix-magento-translation-conflicts/

3
  • Doesn't answer the question in any way that I understand. Jul 7, 2018 at 13:24
  • I gave you my upvote. This is exactly the answer that you are looking for. You ask what it is trying to avoid and he has a pretty solid answer for that. Do not just downvote because you do not understand. Jul 9, 2018 at 9:41
  • "When in-line translation is allowed public function string will translated accordingly. So you need disable it and resume later." Pre-edit, so don't comment on things you do not understand. Jul 10, 2018 at 16:51

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.