1. 程式人生 > >laravel 5.7 resources 本地化 簡體中文

laravel 5.7 resources 本地化 簡體中文

使用方法:

新建目錄【專案目錄/resources/lang/zh】

按以下內容建立檔案,並將內容複製到檔案中

修改

config/app.php

'locale' => 'zh',

'fallback_locale' => 'zh',

'faker_locale' => 'zh_CN',

 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