Home > Enterprise >  How to translate Lang::get('Reset Password Notification') in ResetPassword Notification fo
How to translate Lang::get('Reset Password Notification') in ResetPassword Notification fo

Time:10-05

How to translate Notification messages text? I found it's path, /vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php' copied it's content to app/Notifications/PasswordReset.php`

protected function buildMailMessage($url)
{
    return (new MailMessage)
        ->subject(Lang::get('Reset Password Notification'))
        ->line(Lang::get('You are receiving this email because we received a password reset request for your account.'))
        ->action(Lang::get('Reset Password'), $url)
        ->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
        ->line(Lang::get('If you did not request a password reset, no further action is required.'));
}

How to translate Lang::get('Reset Password Notification') string, where to put my translation, how to set locale?

CodePudding user response:

You have to use the localization files int the resources/lang directory. It is well explained in the documentation: Using Translation Strings As Keys

This works, but are any better options?

There is a nice package to easily manage your translations: Translation Manager

It provides a command to find the translations in the project files, it can also append the new translations string in the localization files and it provides a simple user interface to set the translations for the different languages.

CodePudding user response:

Currently found that I create '{locale}.json'. I put strings in resources/lang/lt.json:

{
"Reset Password Notification": "Slaptažodžio priminimo pranešimas",
}

This works, but are any better options?

  • Related