harunB10
harunB10

Reputation: 5227

Laravel password reset translation

I need to translate Laravel's default password reset blade. I did this (I need en/de translation):

public function toMail($notifiable)
    {
        $language = App::getLocale();

        if ($language == "en") {
            return (new MailMessage)
                ->line('You are receiving this email because we received a password reset request for your account.')
                ->action('Reset Password', url(config('app.url') . route('password.reset', $this->token, false)))
                ->line('If you did not request a password reset, no further action is required.');
        } else {
            return (new MailMessage)
                ->line('Sie erhalten diese E-Mail, weil wir eine Anfrage zum Zurücksetzen des Passworts für Ihr Konto erhalten haben.')
                ->action('Passwort zurücksetzen', url(config('app.url') . route('password.reset', $this->token, false)))
                ->line('Wenn Sie kein Kennwort zurückgesetzt haben, sind keine weiteren Maßnahmen erforderlich.');
        }
    }

But I cannot find where can I translate "Hello!" and:

"If you’re having trouble clicking the "Passwort zurücksetzen" button, copy and paste the URL below into your web browser:"

Right now some parts of email are translated and some of them remained in Engish. Any suggestions?

Upvotes: 3

Views: 2655

Answers (2)

myh34d
myh34d

Reputation: 311

You can change the first 'Hello' using

->greeting("Hallo!")

when overriding the toMail. So, using your example:

(new MailMessage)
                ->greeting("Halo!")
                ->line('Sie erhalten diese E-Mail, weil wir eine Anfrage zum Zurücksetzen des Passworts für Ihr Konto erhalten haben.')
                ->action('Passwort zurücksetzen', url(config('app.url') . route('password.reset', $this->token, false)))
                ->line('Wenn Sie kein Kennwort zurückgesetzt haben, sind keine weiteren Maßnahmen erforderlich.');

For the subcopy, or just for have a complete control over the message, you can simply publish the vendor file and edit it as you prefer.

So publish the vendor file:

php artisan vendor:publish --tag=laravel-notification

then you can edit the file as you wish

views/vendor/notifications/email.blade.php

Upvotes: 1

Artem  Rusinov
Artem Rusinov

Reputation: 176

This text live in /vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php

but you mast not edit this file. instead you should create your own view and link it in MailMessage::markdown (this is markdown view) or MailMessage::view

Upvotes: 1

Related Questions