2017-05-02 5 views
0

LaravelはIlluminate\Auth\Notifications\ResetPasswordクラスを使用してパスワードリセットEメールを送信します。メッセージは英語で書かれています。どのように他の言語に翻訳するのですか?ベンダーファイルを公開しても、このクラスはコピーされません。ベンダーファイルにあり、vcsリポジトリにないので編集できません。Laravel auth電子メールローカライゼーション

答えて

2

電子メール通知はCanResetPassword特質から送信されます。この責任を負うメソッドを無効にして、独自の通知クラスを提供する必要があります。

User extends Authenticatable 
{ 
    // ... 
    public function sendPasswordResetNotification($token) 
    { 
     $this->notify(new MyResetPasswordNotification($token)); 
    } 
    // ... 
} 

と通知を作成します。

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'); 
    } 
} 

は今、あなただけの翻訳を提供する必要があります。