You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fortify.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -423,7 +423,9 @@ The `/forgot-password` endpoint expects a string `email` field. The name of this
423
423
424
424
If the password reset link request was successful, Fortify will redirect the user back to the `/forgot-password` endpoint and send an email to the user with a secure link they can use to reset their password. If the request was an XHR request, a 200 HTTP response will be returned.
425
425
426
-
After being redirected back to the `/forgot-password` endpoint after a successful request, the `status` session variable may be used to display the status of the password reset link request attempt. The value of this session variable will match one of the translation strings defined within your application's `passwords`[language file](/docs/{{version}}/localization):
426
+
After being redirected back to the `/forgot-password` endpoint after a successful request, the `status` session variable may be used to display the status of the password reset link request attempt.
427
+
428
+
The value of the `$status` session variable will match one of the translation strings defined within your application's `passwords`[language file](/docs/{{version}}/localization). If you would like to customize this value and have not published Laravel's language files, you may do so via the `lang:publish` Artisan command:
Copy file name to clipboardExpand all lines: helpers.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -1220,6 +1220,9 @@ The `lang_path` function returns the fully qualified path to your application's
1220
1220
1221
1221
$path = lang_path('en/messages.php');
1222
1222
1223
+
> **Note**
1224
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
1225
+
1223
1226
<aname="method-mix"></a>
1224
1227
#### `mix()` {.collection-method}
1225
1228
@@ -1260,7 +1263,7 @@ The `storage_path` function returns the fully qualified path to your application
1260
1263
<aname="method-__"></a>
1261
1264
#### `__()` {.collection-method}
1262
1265
1263
-
The `__` function translates the given translation string or translation key using your [localization files](/docs/{{version}}/localization):
1266
+
The `__` function translates the given translation string or translation key using your [language files](/docs/{{version}}/localization):
1264
1267
1265
1268
echo __('Welcome to our application');
1266
1269
@@ -2131,7 +2134,7 @@ If no argument is provided to the `str` function, the function returns an instan
2131
2134
<aname="method-trans"></a>
2132
2135
#### `trans()` {.collection-method}
2133
2136
2134
-
The `trans` function translates the given translation key using your [localization files](/docs/{{version}}/localization):
2137
+
The `trans` function translates the given translation key using your [language files](/docs/{{version}}/localization):
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
20
+
17
21
Laravel's localization features provide a convenient way to retrieve strings in various languages, allowing you to easily support multiple languages within your application.
18
22
19
-
Laravel provides two ways to manage translation strings. First, language strings may be stored in files within the `lang` directory. Within this directory, there may be subdirectories for each language supported by the application. This is the approach Laravel uses to manage translation strings for built-in Laravel features such as validation error messages:
23
+
Laravel provides two ways to manage translation strings. First, language strings may be stored in files within the application's `lang` directory. Within this directory, there may be subdirectories for each language supported by the application. This is the approach Laravel uses to manage translation strings for built-in Laravel features such as validation error messages:
20
24
21
25
/lang
22
26
/en
@@ -32,6 +36,15 @@ Or, translation strings may be defined within JSON files that are placed within
32
36
33
37
We'll discuss each approach to managing translation strings within this documentation.
34
38
39
+
<aname="publishing-the-language-files"></a>
40
+
### Publishing The Language Files
41
+
42
+
By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files or create your own, you should scaffold the `lang` directory via the `lang:publish` Artisan command. The `lang:publish` command will create the `lang` directory in your application and publish the default set of language files used by Laravel:
43
+
44
+
```shell
45
+
php artisan lang:publish
46
+
```
47
+
35
48
<aname="configuring-the-locale"></a>
36
49
### Configuring The Locale
37
50
@@ -120,7 +133,7 @@ All language files return an array of keyed strings. For example:
120
133
121
134
For applications with a large number of translatable strings, defining every string with a "short key" can become confusing when referencing the keys in your views and it is cumbersome to continually invent keys for every translation string supported by your application.
122
135
123
-
For this reason, Laravel also provides support for defining translation strings using the "default" translation of the string as the key. Translation files that use translation strings as keys are stored as JSON files in the `lang` directory. For example, if your application has a Spanish translation, you should create a `lang/es.json` file:
136
+
For this reason, Laravel also provides support for defining translation strings using the "default" translation of the string as the key. Language files that use translation strings as keys are stored as JSON files in the `lang` directory. For example, if your application has a Spanish translation, you should create a `lang/es.json` file:
124
137
125
138
```json
126
139
{
@@ -130,7 +143,7 @@ For this reason, Laravel also provides support for defining translation strings
130
143
131
144
#### Key / File Conflicts
132
145
133
-
You should not define translation string keys that conflict with other translation filenames. For example, translating `__('Action')` for the "NL" locale while a `nl/action.php` file exists but a `nl.json` file does not exist will result in the translator returning the contents of `nl/action.php`.
146
+
You should not define translation string keys that conflict with other translation filenames. For example, translating `__('Action')` for the "NL" locale while a `nl/action.php` file exists but a `nl.json` file does not exist will result in the translator returning the entire contents of `nl/action.php`.
@@ -80,7 +80,7 @@ You may disable package discovery for all packages using the `*` character insid
80
80
<aname="service-providers"></a>
81
81
## Service Providers
82
82
83
-
[Service providers](/docs/{{version}}/providers) are the connection point between your package and Laravel. A service provider is responsible for binding things into Laravel's [service container](/docs/{{version}}/container) and informing Laravel where to load package resources such as views, configuration, and localization files.
83
+
[Service providers](/docs/{{version}}/providers) are the connection point between your package and Laravel. A service provider is responsible for binding things into Laravel's [service container](/docs/{{version}}/container) and informing Laravel where to load package resources such as views, configuration, and language files.
84
84
85
85
A service provider extends the `Illuminate\Support\ServiceProvider` class and contains two methods: `register` and `boot`. The base `ServiceProvider` class is located in the `illuminate/support` Composer package, which you should add to your own package's dependencies. To learn more about the structure and purpose of service providers, check out [their documentation](/docs/{{version}}/providers).
86
86
@@ -157,10 +157,10 @@ If your package contains [database migrations](/docs/{{version}}/migrations), yo
157
157
158
158
Once your package's migrations have been registered, they will automatically be run when the `php artisan migrate` command is executed. You do not need to export them to the application's `database/migrations` directory.
159
159
160
-
<aname="translations"></a>
161
-
### Translations
160
+
<aname="language-files"></a>
161
+
### Language Files
162
162
163
-
If your package contains [translation files](/docs/{{version}}/localization), you may use the `loadTranslationsFrom` method to inform Laravel how to load them. For example, if your package is named `courier`, you should add the following to your service provider's `boot` method:
163
+
If your package contains [language files](/docs/{{version}}/localization), you may use the `loadTranslationsFrom` method to inform Laravel how to load them. For example, if your package is named `courier`, you should add the following to your service provider's `boot` method:
164
164
165
165
/**
166
166
* Bootstrap any package services.
@@ -170,14 +170,14 @@ If your package contains [translation files](/docs/{{version}}/localization), yo
Package translations are referenced using the `package::file.line` syntax convention. So, you may load the `courier` package's `welcome` line from the `messages` file like so:
173
+
Package translation lines are referenced using the `package::file.line` syntax convention. So, you may load the `courier` package's `welcome` line from the `messages` file like so:
174
174
175
175
echo trans('courier::messages.welcome');
176
176
177
-
<aname="publishing-translations"></a>
178
-
#### Publishing Translations
177
+
<aname="publishing-language-files"></a>
178
+
#### Publishing Language Files
179
179
180
-
If you would like to publish your package's translations to the application's `lang/vendor` directory, you may use the service provider's `publishes` method. The `publishes` method accepts an array of package paths and their desired publish locations. For example, to publish the translation files for the `courier` package, you may do the following:
180
+
If you would like to publish your package's language files to the application's `lang/vendor` directory, you may use the service provider's `publishes` method. The `publishes` method accepts an array of package paths and their desired publish locations. For example, to publish the language files for the `courier` package, you may do the following:
181
181
182
182
/**
183
183
* Bootstrap any package services.
@@ -191,7 +191,7 @@ If you would like to publish your package's translations to the application's `l
191
191
]);
192
192
}
193
193
194
-
Now, when users of your package execute Laravel's `vendor:publish` Artisan command, your package's translations will be published to the specified publish location.
194
+
Now, when users of your package execute Laravel's `vendor:publish` Artisan command, your package's language files will be published to the specified publish location.
Copy file name to clipboardExpand all lines: passwords.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,9 @@ Before moving on, let's examine this route in more detail. First, the request's
86
86
87
87
The `sendResetLink` method returns a "status" slug. This status may be translated using Laravel's [localization](/docs/{{version}}/localization) helpers in order to display a user-friendly message to the user regarding the status of their request. The translation of the password reset status is determined by your application's `lang/{lang}/passwords.php` language file. An entry for each possible value of the status slug is located within the `passwords` language file.
88
88
89
+
> **Note**
90
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
91
+
89
92
You may be wondering how Laravel knows how to retrieve the user record from your application's database when calling the `Password` facade's `sendResetLink` method. The Laravel password broker utilizes your authentication system's "user providers" to retrieve database records. The user provider used by the password broker is configured within the `passwords` configuration array of your `config/auth.php` configuration file. To learn more about writing custom user providers, consult the [authentication documentation](/docs/{{version}}/authentication#adding-custom-user-providers).
90
93
91
94
> **Note**
@@ -146,7 +149,7 @@ Before moving on, let's examine this route in more detail. First, the request's
146
149
147
150
If the token, email address, and password given to the password broker are valid, the closure passed to the `reset` method will be invoked. Within this closure, which receives the user instance and the plain-text password provided to the password reset form, we may update the user's password in the database.
148
151
149
-
The `reset` method returns a "status" slug. This status may be translated using Laravel's [localization](/docs/{{version}}/localization) helpers in order to display a user-friendly message to the user regarding the status of their request. The translation of the password reset status is determined by your application's `lang/{lang}/passwords.php` language file. An entry for each possible value of the status slug is located within the `passwords` language file.
152
+
The `reset` method returns a "status" slug. This status may be translated using Laravel's [localization](/docs/{{version}}/localization) helpers in order to display a user-friendly message to the user regarding the status of their request. The translation of the password reset status is determined by your application's `lang/{lang}/passwords.php` language file. An entry for each possible value of the status slug is located within the `passwords` language file. If your application does not contain a `lang` directory, you may create it using the `lang:publish` Artisan command.
150
153
151
154
Before moving on, you may be wondering how Laravel knows how to retrieve the user record from your application's database when calling the `Password` facade's `reset` method. The Laravel password broker utilizes your authentication system's "user providers" to retrieve database records. The user provider used by the password broker is configured within the `passwords` configuration array of your `config/auth.php` configuration file. To learn more about writing custom user providers, consult the [authentication documentation](/docs/{{version}}/authentication#adding-custom-user-providers).
@@ -59,11 +58,6 @@ The `config` directory, as the name implies, contains all of your application's
59
58
60
59
The `database` directory contains your database migrations, model factories, and seeds. If you wish, you may also use this directory to hold an SQLite database.
61
60
62
-
<aname="the-lang-directory"></a>
63
-
#### The Lang Directory
64
-
65
-
The `lang` directory houses all of your application's language files.
Copy file name to clipboardExpand all lines: validation.md
+14-2
Original file line number
Diff line number
Diff line change
@@ -199,7 +199,10 @@ So, in our example, the user will be redirected to our controller's `create` met
199
199
200
200
Laravel's built-in validation rules each have an error message that is located in your application's `lang/en/validation.php` file. Within this file, you will find a translation entry for each validation rule. You are free to change or modify these messages based on the needs of your application.
201
201
202
-
In addition, you may copy this file to another translation language directory to translate the messages for your application's language. To learn more about Laravel localization, check out the complete [localization documentation](/docs/{{version}}/localization).
202
+
In addition, you may copy this file to another language directory to translate the messages for your application's language. To learn more about Laravel localization, check out the complete [localization documentation](/docs/{{version}}/localization).
203
+
204
+
> **Warning**
205
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
203
206
204
207
<aname="quick-xhr-requests-and-validation"></a>
205
208
#### XHR Requests & Validation
@@ -736,7 +739,10 @@ The `has` method may be used to determine if any error messages exist for a give
736
739
737
740
Laravel's built-in validation rules each have an error message that is located in your application's `lang/en/validation.php` file. Within this file, you will find a translation entry for each validation rule. You are free to change or modify these messages based on the needs of your application.
738
741
739
-
In addition, you may copy this file to another translation language directory to translate the messages for your application's language. To learn more about Laravel localization, check out the complete [localization documentation](/docs/{{version}}/localization).
742
+
In addition, you may copy this file to another language directory to translate the messages for your application's language. To learn more about Laravel localization, check out the complete [localization documentation](/docs/{{version}}/localization).
743
+
744
+
> **Warning**
745
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
@@ -759,6 +765,9 @@ Many of Laravel's built-in error messages include an `:attribute` placeholder th
759
765
'email' => 'email address',
760
766
],
761
767
768
+
> **Warning**
769
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
770
+
762
771
<aname="specifying-values-in-language-files"></a>
763
772
### Specifying Values In Language Files
764
773
@@ -782,6 +791,9 @@ Instead of displaying `cc` as the payment type value, you may specify a more use
782
791
],
783
792
],
784
793
794
+
> **Warning**
795
+
> By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command.
796
+
785
797
After defining this value, the validation rule will produce the following error message:
0 commit comments