我正在嘗試將我的錯誤消息翻譯成法語。但是驗證消息包含在app/Rules/MatchOldPassword.php文件我已經翻譯了 validation.php 文件中的錯誤消息,但是如何翻譯這條位于不同路徑的錯誤消息這是我的 MatchOldPassword.php 代碼<?phpnamespace App\Rules;use Illuminate\Contracts\Validation\Rule;use Illuminate\Support\Facades\Hash;class MatchOldPassword implements Rule{ /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { return Hash::check($value, auth()->user()->password); } /** * Get the validation error message. * * @return string */ public function message() { return 'The :attribute need to be matched the with old password.'; }}
1 回答

12345678_0001
TA貢獻1802條經驗 獲得超5個贊
使用__
方法進行字符串翻譯
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return __('validation.<key>'); // the key is the key specified in your validation file
}
- 1 回答
- 0 關注
- 166 瀏覽
添加回答
舉報
0/150
提交
取消