我正在尝试更改默认值subject
Laravel 5.7 附带的验证电子邮件中的字段。我该如何以及在哪里更改它?我已经到处和网上搜索过了。因为它是全新的,所以我找不到答案。
您不需要编写任何代码。该通知将所有字符串包装在 Lang 类中,以便您可以提供从英语到另一种语言的翻译字符串,如果您只想更改措辞,甚至可以提供从英语到英语的翻译字符串。
查看 /vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(
Lang::getFromJson('Verify Email Address'),
$this->verificationUrl($notifiable)
)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
}
您可以在那里看到所有字符串。
如果 resources/lang 文件夹中还没有 en.json 文件,请创建一个文件。
添加原始字符串和替换字符串。
例如
{
"Verify Email Address": "My preferred subject",
"Please click the button below to verify your email address.":"Another translation"
}
要翻译为另一种语言,请更改 config/app.php 中的区域设置并使用 locale.json 创建翻译文件
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)