its in resources/lang/en/passwords.php
How to translate PasswordResetEmail?
Hello awesome people!
How I can override PassworResetEmail, I want to translate it, I forund it in one place but when I do composer update all translation is lost ;(
Thanks! P.S. When I request password reset email I got this notificaiont
We have e-mailed your password reset link!
Where I can translate it also:)
Check https://laravel.com/docs/5.3/passwords#password-customization and look for Password Broker customization
@Snapey I read that, but could'nt understand where to put my translated code. Can you please explain little more?
public function toMail($notifiable)
{
return (new MailMessage)
->line( tr("b/notifications.you-received-this-mail-because","You are receiving this email because we received a password reset request for your account.") )
->action( tr("b/notifications.reset-password","Reset Password"), url('password/reset', $this->token))
->line( tr("b/notifications.if-you-did-not-request-a-passowrd-reset","If you did not request a password reset, no further action is required.") );
}
You put fhe translations in your normal lang/ directory.
I have done it, it worked untill I updated dependencies! So this part of code was replaced, so I am wondering, where do I put this code so it would not overvrite on updates. :)
May be a working example may help.
@roulendz Did you change the reset password notification in vendor or did you make your own implementation?
Assuming you have working boilerplate auth functions but you need to change the text of the password reset email for instance, to customise it for your language;
Create a notification
php artisan make:notification MailResetPasswordToken
edit this file which you find in a new folder App\Notifications
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class MailResetPasswordToken extends Notification
{
use Queueable;
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject("Reset your password")
->line("Hey, did you forget your password? Click the button to reset it.")
->action('Reset Password', url('password/reset', $this->token))
->line('Thankyou for being a friend');
}
}
Override the send password reset trait with your local implementation in your User.php user model
/**
* Send a password reset email to the user
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new MailResetPasswordToken($token));
}
remembering to import the class at the top of the user model
use App\Notifications\MailResetPasswordToken;
If you need to alter the layout of the message, including the text "If you’re having trouble clicking the "Reset Password" button," then you need to run
php artisan vendor:publish
and then edit the files in /resources/views/vendor/notifications
I just added a pull-request that allows for translating the PasswordReset notification in a json translation file.
Please or to participate in this conversation.