OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions How to translate in oro email

This topic contains 2 replies, has 3 voices, and was last updated by  Artem Liubeznyi 7 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #35972


    Hi all,

    I’m using the Oro EmailRenderer for rendering an email.

    The problem occurs when I want to translate a variable:

    I get an error:

    The template for Content (English) has syntax error: The filter “trans” does not exist at line 1

    Is it possible to translate in email templates?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #35973

    Andrey Mishchenko

    Hello, cardiac!

    You are getting this error because Translation Extension is not added into EmailRenderer’s environment.
    Also ‘trans’ filter usage is restricted by Twig’s security policy in sandbox mode (you can find all allowed tags, filters, functions etc at services.yml file of EmailBundle).
    To achieve your goals would be enough to add TranslationExtension to EmailRenderer and resolve usage of ‘trans’ filter. I believe TwigSandboxConfigurationPass class is the right place to add your code:
    const TRANSLATION_EXTENSION_SERVICE_KEY = 'twig.extension.trans';
    // inside if statement of process method:
    $filters = $securityPolicyDef->getArgument(1); // get allowed filters array
    $filters = array_merge($filters, array('trans')); // add trans filter to it
    $securityPolicyDef->replaceArgument(1, $filters); // set modified argument to definition
    ); // enable Translation extension for EmailRenderer environment

    That’s it! And don’t forget to clear your cache to recompile service container.


    Artem Liubeznyi

    This will make a good feature, we will add it to our backlog. Thanks for the suggestion!

Viewing 2 replies - 1 through 2 (of 2 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No