Reputation: 1167
Laravel uses Illuminate\Auth\Notifications\ResetPassword
class to send password reset email. The message is written in english. How do I translate it into another language. Publishing vendor files doesn't copy this class. I can't edit it since it is in vendor files and is not in the vcs repository.
Upvotes: 0
Views: 212
Reputation: 1283
The email notification is sent from CanResetPassword
trait, you need to override the method responsible for this and provide your own notification class.
User extends Authenticatable
{
// ...
public function sendPasswordResetNotification($token)
{
$this->notify(new MyResetPasswordNotification($token));
}
// ...
}
And create the notification:
MyResetPasswordNotification extends Notification
{
public $token;
public function __construct($token)
{
$this->token = $token;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->line(trans('reset_password.first_line'))
->action(trans('reset_password.action', ['route' => route('password.reset', $this->token)))
->line(trans('reset_password.last_line');
}
}
Now you just need to provide the translations.
Upvotes: 2