亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

laravel 中的錯誤信息翻譯問題

laravel 中的錯誤信息翻譯問題

PHP
大話西游666 2022-12-11 09:46:24
我正在嘗試將我的錯誤消息翻譯成法語。但是驗證消息包含在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

}


查看完整回答
反對 回復 2022-12-11
  • 1 回答
  • 0 關注
  • 166 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號