laravel 中的错误消息翻译问题
Error message translation issue in laravel
我正在尝试将我的错误消息翻译成法语。但是验证消息包含在
app/Rules/MatchOldPassword.php
文件
我已经翻译了 validation.php 文件中的错误信息,但是我该如何翻译这个位于不同路径的错误信息
这是我的 MatchOldPassword.php
代码
<?php
namespace 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.';
}
}
使用__
方法进行字符串翻译
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return __('validation.<key>'); // the key is the key specified in your validation file
}
我正在尝试将我的错误消息翻译成法语。但是验证消息包含在
app/Rules/MatchOldPassword.php
文件
我已经翻译了 validation.php 文件中的错误信息,但是我该如何翻译这个位于不同路径的错误信息
这是我的 MatchOldPassword.php
代码<?php
namespace 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.';
}
}
使用__
方法进行字符串翻译
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return __('validation.<key>'); // the key is the key specified in your validation file
}