佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Laravel修改驗(yàn)證提示信息為中文的示例

Laravel修改驗(yàn)證提示信息為中文的示例

熱門標(biāo)簽:電子圍欄 團(tuán)購(gòu)網(wǎng)站 阿里云 服務(wù)器配置 Mysql連接數(shù)設(shè)置 科大訊飛語(yǔ)音識(shí)別系統(tǒng) Linux服務(wù)器 銀行業(yè)務(wù)

1.覆蓋提示信息:

打開resource/lang/en/validation.php注釋掉英文提示信息

將下面的提示信息覆蓋英文提示信息

?php
 
return [
 
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/
 
'accepted'       => ':attribute 必須接受',
'active_url'      => ':attribute 必須是一個(gè)合法的 URL',
'after'        => ':attribute 必須是 :date 之后的一個(gè)日期',
'after_or_equal'    => ':attribute 必須是 :date 之后或相同的一個(gè)日期',
'alpha'        => ':attribute 只能包含字母',
'alpha_dash'      => ':attribute 只能包含字母、數(shù)字、中劃線或下劃線',
'alpha_num'      => ':attribute 只能包含字母和數(shù)字',
'array'        => ':attribute 必須是一個(gè)數(shù)組',
'before'        => ':attribute 必須是 :date 之前的一個(gè)日期',
'before_or_equal'   => ':attribute 必須是 :date 之前或相同的一個(gè)日期',
'between'       => [
  'numeric' => ':attribute 必須在 :min 到 :max 之間',
  'file'  => ':attribute 必須在 :min 到 :max KB 之間',
  'string' => ':attribute 必須在 :min 到 :max 個(gè)字符之間',
  'array'  => ':attribute 必須在 :min 到 :max 項(xiàng)之間',
],
'boolean'       => ':attribute 字符必須是 true 或 false',
'confirmed'      => ':attribute 二次確認(rèn)不匹配',
'date'         => ':attribute 必須是一個(gè)合法的日期',
'date_format'     => ':attribute 與給定的格式 :format 不符合',
'different'      => ':attribute 必須不同于 :other',
'digits'        => ':attribute 必須是 :digits 位.',
'digits_between'    => ':attribute 必須在 :min 和 :max 位之間',
'dimensions'      => ':attribute 具有無(wú)效的圖片尺寸',
'distinct'       => ':attribute 字段具有重復(fù)值',
'email'        => ':attribute 必須是一個(gè)合法的電子郵件地址',
'exists'        => '選定的 :attribute 是無(wú)效的.',
'file'         => ':attribute 必須是一個(gè)文件',
'filled'        => ':attribute 的字段是必填的',
'image'        => ':attribute 必須是 jpeg, png, bmp 或者 gif 格式的圖片',
'in'          => '選定的 :attribute 是無(wú)效的',
'in_array'       => ':attribute 字段不存在于 :other',
'integer'       => ':attribute 必須是個(gè)整數(shù)',
'ip'          => ':attribute 必須是一個(gè)合法的 IP 地址。',
'json'         => ':attribute 必須是一個(gè)合法的 JSON 字符串',
'max'         => [
  'numeric' => ':attribute 的最大長(zhǎng)度為 :max 位',
  'file'  => ':attribute 的最大為 :max',
  'string' => ':attribute 的最大長(zhǎng)度為 :max 字符',
  'array'  => ':attribute 的最大個(gè)數(shù)為 :max 個(gè).',
],
'mimes'        => ':attribute 的文件類型必須是 :values',
'min'         => [
  'numeric' => ':attribute 的最小長(zhǎng)度為 :min 位',
  'file'  => ':attribute 大小至少為 :min KB',
  'string' => ':attribute 的最小長(zhǎng)度為 :min 字符',
  'array'  => ':attribute 至少有 :min 項(xiàng)',
],
'not_in'        => '選定的 :attribute 是無(wú)效的',
'numeric'       => ':attribute 必須是數(shù)字',
'present'       => ':attribute 字段必須存在',
'regex'        => ':attribute 格式是無(wú)效的',
'required'       => ':attribute 字段是必須的',
'required_if'     => ':attribute 字段是必須的當(dāng) :other 是 :value',
'required_unless'   => ':attribute 字段是必須的,除非 :other 是在 :values 中',
'required_with'    => ':attribute 字段是必須的當(dāng) :values 是存在的',
'required_with_all'  => ':attribute 字段是必須的當(dāng) :values 是存在的',
'required_without'   => ':attribute 字段是必須的當(dāng) :values 是不存在的',
'required_without_all' => ':attribute 字段是必須的當(dāng) 沒有一個(gè) :values 是存在的',
'same'         => ':attribute 和 :other 必須匹配',
'size'         => [
  'numeric' => ':attribute 必須是 :size 位',
  'file'  => ':attribute 必須是 :size KB',
  'string' => ':attribute 必須是 :size 個(gè)字符',
  'array'  => ':attribute 必須包括 :size 項(xiàng)',
],
'string'        => ':attribute 必須是一個(gè)字符串',
'timezone'       => ':attribute 必須是個(gè)有效的時(shí)區(qū).',
'unique'        => ':attribute 已存在',
'url'         => ':attribute 無(wú)效的格式',
 
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
 
'custom' => [
  'attribute-name' => [
    'rule-name' => 'custom-message',
  ],
],
 
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
 
'attributes' => [
  // 'name'     => '名字',
  // 'age'     => '年齡',
],
 
];

2.安裝中文信息提示包

composer require "overtrue/laravel-lang:~3.0"

注冊(cè)服務(wù)提供者: config/app.php

'providers' => [
  // Illuminate\Translation\TranslationServiceProvider::class,
  Overtrue\LaravelLang\TranslationServiceProvider::class,
]

修改語(yǔ)言:config/app.php

'locale' => 'zh-CN',

以上這篇Laravel修改驗(yàn)證提示信息為中文的示例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • Laravel 錯(cuò)誤提示本地化的實(shí)現(xiàn)
  • Laravel 實(shí)現(xiàn)添加多語(yǔ)言提示信息

標(biāo)簽:衢州 廣元 江蘇 棗莊 衡水 大理 萍鄉(xiāng) 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Laravel修改驗(yàn)證提示信息為中文的示例》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    岗巴县| 喀喇沁旗| 景东| 霞浦县| 翁源县| 肥东县| 新郑市| 醴陵市| 洮南市| 芜湖县| 昌图县| 榆中县| 安徽省| 合川市| 南宁市| 宜丰县| 克山县| 米脂县| 吉隆县| 方山县| 桐柏县| 江都市| 巴林右旗| 霸州市| 托克逊县| 会宁县| 垦利县| 麻城市| 正安县| 凉城县| 小金县| 永川市| 开封县| 虎林市| 朝阳区| 永宁县| 丰都县| 青海省| 邛崃市| 博野县| 荥阳市|