Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

[Proposal] Translate rendered email views #1318

Open
amadeann opened this issue Sep 15, 2018 · 2 comments
Open

[Proposal] Translate rendered email views #1318

amadeann opened this issue Sep 15, 2018 · 2 comments

Comments

@amadeann
Copy link

amadeann commented Sep 15, 2018

#23178 added the ability to change locale in sent/queued Mailables. This functionality is currently missing for rendered views. I am referring to the functionality described here in the documentation.

The easiest implementation that I could think of would be duplicating the functionality of 'hot translation' implemented in the send method of Mailable.

@amadeann amadeann changed the title Translate rendered email views [Proposal] Translate rendered email views Sep 15, 2018
@derekmd
Copy link

derekmd commented Oct 5, 2018

For testing translated mailable views in the browser, is there much difference between:

Route::get('mail-order', function () {
    app()->setLocale('fr');

    return new \App\Mail\OrderConfirmation(
        new App\Order::latest()->first()
    );
});

And adding that support in Mailable like so:

Route::get('mail-order', function () {
    return (new \App\Mail\OrderConfirmation(
        new App\Order::latest()->first()
    ))->locale('fr');
});

Or are you rendering mailables in production?

@amadeann
Copy link
Author

amadeann commented Oct 6, 2018

Rendering in production - I want customer support to preview the auto-generated mailable before sending them to customers. The translation is determined by who the translated mailable is sent to (end customer), not by the person previewing it - therefore it makes more sense to set the language directly in the mailable, and not the route/controller.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants