-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Mail::to($email)->send((new Mail())->local('en')) won't override the localization (As documented) #27023
Comments
You should call the locale method before sending, not after. |
This is totally makes sense, but what about this? \Mail::to('[email protected]')->send((new NewOrder($order)->locale('en'))); as you can see, the local is set before the mail was sent, but still didn't work. to be honest I was about to use App::setLocal() to work around this issue, that PR saved me. |
Yeah, I never touched Mohamed's original The I didn't realize the docs were written like that. I'll submit a pull request later to correct it, calling |
Thank you very much, since it was just misunderstanding, I will close this issue. |
Description:
When trying to send an email with specific local using ->local() method on new Mailable class, example:
while if you use ->local() on the Mail directly before ->send() method, it will override the local
Steps To Reproduce:
tr;dr:
simply use ->local('en') on any Mailable instance, it won't change the localization of that email.
Detailed:
Additional details:
This is the code I use exactly:
The default local is English, I am trying to send this email in Arabic, it never arrived in Arabic except with this code:
Not overriding method
I discovered this issue from Laravel documentations here:
https://laravel.com/docs/5.7/mail#localizing-mailables
Link for this method on the repository:
framework/src/Illuminate/Mail/Mailable.php
Lines 417 to 428 in 2219c7d
Overriding method
and found the working method here:
#25752
Link for this method on the repository:
framework/src/Illuminate/Mail/PendingMail.php
Lines 56 to 67 in 2219c7d
The text was updated successfully, but these errors were encountered: