语言包git库: https://github.com/caouecs/Laravel-lang
这里面有68国语言,我这里只需要中文包,因此,我就在另外一个地方clone了这个仓库,然后复制E:\Laravel-lang\src\zh-CN这个文件夹到**D:\phpStudy\WWW\kidpad_new\resources\lang\zh-CN**这里,即可!
配置文件路径:
D:\phpStudy\WWW\xxx\config\app.php修改语言设置:
'locale' => 'zh-CN', #这个和你的语言包目录夹的名字一致即可。 // 'locale' => 'en',配置好语言包以后,提示语确实变了,但是里面话是有你的英文参数名,例如,student_info_id,这时候提示语就是英汉混杂的。例如: student_info_id 必须是数字,类似这种提示,这让人很不爽,我想自定义这个student_info_id的提示语。Larave这点做的比较好,可以自定义字段的翻译,就是那个 :attribute 的翻译。 例如,下面就是我自定义的字段翻译,这个可以根据你项目来,你项目里面用到了哪些参数验证,你就对应着写就行了。配置路径D:\phpStudy\WWW\kidpad_new\resources\lang\zh-CN\validation.php 经过这个配置以后,提示语就会变成:学生ID必须为数字。 就完全实现自定义提示语了,这个还是很不错的。
/* |-------------------------------------------------------------------------- | 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' => '名称', 'username' => '用户名', 'email' => '邮箱', 'first_name' => '名', 'last_name' => '姓', 'password' => '密码', 'password_confirmation' => '确认密码', 'city' => '城市', 'country' => '国家', 'address' => '地址', 'phone' => '电话', 'mobile' => '手机', 'age' => '年龄', 'sex' => '性别', 'gender' => '性别', 'day' => '天', 'month' => '月', 'year' => '年', 'hour' => '时', 'minute' => '分', 'second' => '秒', 'title' => '标题', 'content' => '内容', 'description' => '描述', 'excerpt' => '摘要', 'date' => '日期', 'time' => '时间', 'available' => '可用的', 'size' => '大小', ##以下是自定义的! 'telephone' => '手机号', 'type' => '类型', 'area_phone_number' => '手机区号', 'student_info_id' => '学生ID', 'lesson_appointment_id' => '预约课程ID', 'version' => '版本', 'interface_type' => '设备类型', 'parent_id' => '家长ID', 'old_password' => '旧密码', 'new_password' => '新密码', 'confirm_password' => '确认密码', 'auth_code' => '验证码', 'country_id' => '国家ID', 'wechat' => '微信', 'chinese_name' => '中文名', 'english_name' => '英文名', 'province_id' => '省份ID', 'city_id' => '城市ID', 'customer_id' => '用户ID', 'birthday' => '生日', 'course_id' => '课程ID', 'page' => '页', 'perPage' => '每页', 'feedback_type' => '反馈类型', 'content' => '内容', 'room_id' => '房间ID', 'token' => 'Token凭证', ],https://laravel.com/docs/5.5/localization#overriding-package-language-files