laravel 5.7 resources 本地化 简体中文

使用方法:

新建目录【项目目录/resources/lang/zh】

按以下内容创建文件,并将内容复制到文件中

修改

config/app.php

'locale' => 'zh',

'fallback_locale' => 'zh',

 1 <?php
 2 
 3 return [
 4 
 5     /*
 6     |--------------------------------------------------------------------------
 7     | Authentication Language Lines
 8     |--------------------------------------------------------------------------
 9     |
10     | The following language lines are used during authentication for various
11     | messages that we need to display to the user. You are free to modify
12     | these language lines according to your application's requirements.
13     |
14     */
15 
16     'failed' => '当前凭证与我们的记录不相符',
17     'throttle' => '登录操作太频繁,请等待 :seconds 秒后重试。',
18 ];
auth.php
 1 <?php
 2 
 3 return [
 4 
 5     /*
 6     |--------------------------------------------------------------------------
 7     | Pagination Language Lines
 8     |--------------------------------------------------------------------------
 9     |
10     | The following language lines are used by the paginator library to build
11     | the simple pagination links. You are free to change them to anything
12     | you want to customize your views to better match your application.
13     |
14     */
15 
16     'previous' => '&laquo; 上一页',
17     'next' => '下一页 &raquo;',
18 
19 ];
pagination.php
 1 <?php
 2 
 3 return [
 4 
 5     /*
 6     |--------------------------------------------------------------------------
 7     | Password Reset Language Lines
 8     |--------------------------------------------------------------------------
 9     |
10     | The following language lines are the default lines which match reasons
11     | that are given by the password broker for a password update attempt
12     | has failed, such as for an invalid token or invalid new password.
13     |
14     */
15 
16     'password' => '密码必须最少为 6 个字符并与确认密码相同。',
17     'reset' => '您的密码已重置!',
18     'sent' => '我们已将密码重置链接发送到您的邮箱!',
19     'token' => '重置密码的令牌无效。',
20     'user' => "未找到使用此邮箱的用户。",
21 
22 ];
passwords.php
  1 <?php
  2 
  3 return [
  4 
  5     /*
  6     |--------------------------------------------------------------------------
  7     | Validation Language Lines
  8     |--------------------------------------------------------------------------
  9     |
 10     | The following language lines contain the default error messages used by
 11     | the validator class. Some of these rules have multiple versions such
 12     | as the size rules. Feel free to tweak each of these messages here.
 13     |
 14     */
 15 
 16     'accepted' => ':attribute 必须为已接受',
 17     'active_url' => ':attribute 不是有效的 URL',
 18     'after' => ':attribute 必须大于 :date',
 19     'after_or_equal' => ':attribute 必须大于或等于 :date',
 20     'alpha' => ':attribute 可接受类型:字母',
 21     'alpha_dash' => ':attribute 可接受类型:字母、数字、短划线和下划线',
 22     'alpha_num' => ':attribute 可接受类型:字母、数字',
 23     'array' => ':attribute 可接受类型:数组',
 24     'before' => ':attribute 必须小于 :date',
 25     'before_or_equal' => ':attribute 必须小于或等于 :date',
 26     'between' => [
 27         'numeric' => ':attribute 必须介于 [:min - :max] 之间',
 28         'file' => ':attribute 最小::min KB,最大::max KB',
 29         'string' => ':attribute 最少::min 个字符,最多::max 个字符',
 30         'array' => ':attribute 最少::min 项,最多::max 项',
 31     ],
 32     'boolean' => ':attribute 可接受类型:是 或 否',
 33     'confirmed' => 'The :attribute confirmation does not match.',
 34     'date' => ':attribute 不是有效的日期',
 35     'date_format' => ':attribute 格式错误,格式::format.',
 36     'different' => ':attribute 不能等于 :other',
 37     'digits' => ':attribute 必须是 :digits 位数',
 38     'digits_between' => ':attribute 最少 :min 位数,最多::max 位数',
 39     'dimensions' => ':attribute 图片尺寸不匹配',
 40     'distinct' => ':attribute 已存在相同的选项',
 41     'email' => ':attribute 不是有效的邮箱地址',
 42     'exists' => '不存在的选项::attribute',
 43     'file' => ':attribute 必须是一个有效的文件',
 44     'filled' => ':attribute 必须填写',
 45     'gt' => [
 46         'numeric' => ':attribute 必须大于 :value.',
 47         'file' => ':attribute 必须大于 :value KB',
 48         'string' => ':attribute 必须大于 :value 个字符',
 49         'array' => ':attribute 必须大于 :value 项',
 50     ],
 51     'gte' => [
 52         'numeric' => ':attribute 必须大于或等于 :value',
 53         'file' => ':attribute 必须大于或等于 :value KB',
 54         'string' => ':attribute 必须大于或等于 :value 个字符',
 55         'array' => ':attribute 必须大于或等于 :value 项',
 56     ],
 57     'image' => ':attribute 必须是一个图像',
 58     'in' => ':attribute 不是一个有效的值',
 59     'in_array' => ':other 不包含 :attribute',
 60     'integer' => ':attribute 必须是整数',
 61     'ip' => ':attribute 无效的 IP 地址',
 62     'ipv4' => ':attribute 无效的 IPv4 地址',
 63     'ipv6' => ':attribute 无效的 IPv6 地址',
 64     'json' => ':attribute 无效的 JSON 字符串',
 65     'lt' => [
 66         'numeric' => ':attribute 必须小于 :value.',
 67         'file' => ':attribute 必须小于 :value KB',
 68         'string' => ':attribute 必须小于 :value 个字符',
 69         'array' => ':attribute 必须小于 :value 项',
 70     ],
 71     'lte' => [
 72         'numeric' => ':attribute 必须小于或等于 :value',
 73         'file' => ':attribute 必须小于或等于 :value KB',
 74         'string' => ':attribute 必须小于或等于 :value 个字符',
 75         'array' => ':attribute 必须小于或等于 :value 项',
 76     ],
 77     'max' => [
 78         'numeric' => ':attribute 不能大于 :max',
 79         'file' => ':attribute 不能大于 :max KB',
 80         'string' => ':attribute 不能大于 :max 个字符',
 81         'array' => ':attribute 不能多于 :max 项',
 82     ],
 83     'mimes' => ':attribute 的文件类型必须是: :values.',
 84     'mimetypes' => ':attribute 的文件类型必须是: :values.',
 85     'min' => [
 86         'numeric' => ':attribute 最小值::min.',
 87         'file' => ':attribute 不能小于 :min KB',
 88         'string' => ':attribute 最少 :min 个字符',
 89         'array' => ':attribute 最少包含 :min 项',
 90     ],
 91     'not_in' => '当前选项 :attribute 无效',
 92     'not_regex' => ':attribute 格式错误',
 93     'numeric' => ':attribute 必须是数值',
 94     'present' => ':attribute 必须存在',
 95     'regex' => ':attribute 格式错误',
 96     'required' => '必须指定::attribute',
 97     'required_if' => '当 :other 等于 :value 时,必须指定::attribute',
 98     'required_unless' => '除非 :values 包含 :other,否则必须指定::attribute',
 99     'required_with' => '当 :values 存在时,必须指定::attribute',
100     'required_with_all' => '当 :values 存在时,必须指定::attribute',
101     'required_without' => '当 :values 不存在时,必须指定::attribute',
102     'required_without_all' => '当 :values 未指定时,必须指定::attribute',
103     'same' => ':attribute 必须与 :other 相匹配',
104     'size' => [
105         'numeric' => ':attribute 必须是 :size',
106         'file' => ':attribute 必须是 :size KB',
107         'string' => ':attribute 必须是 :size 个字符',
108         'array' => ':attribute 必须是 :size 项',
109     ],
110     'string' => ':attribute 必须是字符串',
111     'timezone' => ':attribute 必须是有效的时区',
112     'unique' => ':attribute 不能与已存在的项相同',
113     'uploaded' => ':attribute 上传失败',
114     'url' => ':attribute 格式错误',
115     'uuid' => ':attribute 无效的 UUID 格式',
116 
117     /*
118     |--------------------------------------------------------------------------
119     | Custom Validation Language Lines
120     |--------------------------------------------------------------------------
121     |
122     | Here you may specify custom validation messages for attributes using the
123     | convention "attribute.rule" to name the lines. This makes it quick to
124     | specify a specific custom language line for a given attribute rule.
125     |
126     */
127 
128     'custom' => [
129         'attribute-name' => [
130             'rule-name' => 'custom-message',
131         ],
132     ],
133 
134     /*
135     |--------------------------------------------------------------------------
136     | Custom Validation Attributes
137     |--------------------------------------------------------------------------
138     |
139     | The following language lines are used to swap our attribute placeholder
140     | with something more reader friendly such as "E-Mail Address" instead
141     | of "email". This simply helps us make our message more expressive.
142     |
143     */
144 
145     'attributes' => [],
146 
147 ];
validation.php
原文地址:https://www.cnblogs.com/tdhao/p/9945938.html