Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mime] Add TemplatedEmail::locale() to set the locale for the email rendering #51690

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Sep 18, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Add LocaleSwitcher to TemplatedEmail BodyRenderer. Currently it is not possible to render a twig template or a converter in a specific locale context.

It is common to send the email in the language of the receiver.

Usage

$email = (new TemplatedEmail())
    ->to('fabien@symfony.com')
    ->from('helene@symfony.com')
    ->subject('Hallo!')
    ->locale('de')
    ->textTemplate('email.txt.twig')
    ->htmlTemplate('email.html.twig')
    ->context($context)
;

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Please just add a line in the changelog of the bridge.

@nicolas-grekas nicolas-grekas changed the title [TwigBridge][Mime] Add LocaleSwitcher to TemplatedEmail BodyRenderer [TwigBridge][Mime] Add TemplatedEmail::locale() to set the locale for the email rendering Sep 19, 2023
@nicolas-grekas
Copy link
Member

ah, can you please check tests?

@nicolas-grekas
Copy link
Member

tests still :)

@nicolas-grekas nicolas-grekas added this to the 6.4 milestone Sep 25, 2023
@carsonbot carsonbot changed the title [TwigBridge][Mime] Add TemplatedEmail::locale() to set the locale for the email rendering [Mime] Add TemplatedEmail::locale() to set the locale for the email rendering Sep 25, 2023
@fabpot fabpot force-pushed the feature/local-switcher-templated-emails branch from 78e582e to d912384 Compare October 1, 2023 08:40
@fabpot
Copy link
Member

fabpot commented Oct 1, 2023

Thank you @alexander-schranz.

@fabpot fabpot merged commit decb566 into symfony:6.4 Oct 1, 2023
3 of 9 checks passed
This was referenced Oct 21, 2023
@alexander-schranz alexander-schranz deleted the feature/local-switcher-templated-emails branch February 29, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants