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: controllers.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -326,7 +326,7 @@ When using a custom keyed implicit binding as a nested route parameter, Laravel
326
326
<aname="restful-localizing-resource-uris"></a>
327
327
### Localizing Resource URIs
328
328
329
-
By default, `Route::resource` will create resource URIs using English verbs. If you need to localize the `create` and `edit` action verbs, you may use the `Route::resourceVerbs` method. This may be done at the beginning of the `boot` method within your application's `App\Providers\RouteServiceProvider`:
329
+
By default, `Route::resource` will create resource URIs using English verbs and plural rules. If you need to localize the `create` and `edit` action verbs, you may use the `Route::resourceVerbs` method. This may be done at the beginning of the `boot` method within your application's `App\Providers\RouteServiceProvider`:
330
330
331
331
/**
332
332
* Define your route model bindings, pattern filters, etc.
@@ -343,11 +343,11 @@ By default, `Route::resource` will create resource URIs using English verbs. If
343
343
// ...
344
344
}
345
345
346
-
Once the verbs have been customized, a resource route registration such as `Route::resource('fotos', PhotoController::class)` will produce the following URIs:
346
+
Laravel's pluralizer supports [several different languages which you may configure based on your needs](/docs/{{version}}/localization#pluralization-language). Once the verbs and pluralization language have been customized, a resource route registration such as `Route::resource('publicacion', PublicacionController::class)` will produce the following URIs:
Copy file name to clipboardExpand all lines: helpers.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -1583,7 +1583,7 @@ The `Str::padRight` method wraps PHP's `str_pad` function, padding the right sid
1583
1583
<aname="method-str-plural"></a>
1584
1584
#### `Str::plural()` {.collection-method}
1585
1585
1586
-
The `Str::plural` method converts a singular word string to its plural form. This function currently only supports the English language:
1586
+
The `Str::plural` method converts a singular word string to its plural form. This function supports [any of the languages support by Laravel's pluralizer](/docs/{{version}}/localization#pluralization-language):
1587
1587
1588
1588
use Illuminate\Support\Str;
1589
1589
@@ -1610,7 +1610,7 @@ You may provide an integer as a second argument to the function to retrieve the
1610
1610
<aname="method-str-plural-studly"></a>
1611
1611
#### `Str::pluralStudly()` {.collection-method}
1612
1612
1613
-
The `Str::pluralStudly` method converts a singular word string formatted in studly caps case to its plural form. This function currently only supports the English language:
1613
+
The `Str::pluralStudly` method converts a singular word string formatted in studly caps case to its plural form. This function supports [any of the languages support by Laravel's pluralizer](/docs/{{version}}/localization#pluralization-language):
1614
1614
1615
1615
use Illuminate\Support\Str;
1616
1616
@@ -1721,7 +1721,7 @@ The `Str::reverse` method reverses the given string:
1721
1721
<aname="method-str-singular"></a>
1722
1722
#### `Str::singular()` {.collection-method}
1723
1723
1724
-
The `Str::singular` method converts a string to its singular form. This function currently only supports the English language:
1724
+
The `Str::singular` method converts a string to its singular form. This function supports [any of the languages support by Laravel's pluralizer](/docs/{{version}}/localization#pluralization-language):
1725
1725
1726
1726
use Illuminate\Support\Str;
1727
1727
@@ -2539,7 +2539,7 @@ The `pipe` method allows you to transform the string by passing its current valu
2539
2539
<aname="method-fluent-str-plural"></a>
2540
2540
#### `plural` {.collection-method}
2541
2541
2542
-
The `plural` method converts a singular word string to its plural form. This function currently only supports the English language:
2542
+
The `plural` method converts a singular word string to its plural form. This function supports [any of the languages support by Laravel's pluralizer](/docs/{{version}}/localization#pluralization-language):
2543
2543
2544
2544
use Illuminate\Support\Str;
2545
2545
@@ -2683,7 +2683,7 @@ The `scan` method parses input from a string into a collection according to a fo
2683
2683
<aname="method-fluent-str-singular"></a>
2684
2684
#### `singular` {.collection-method}
2685
2685
2686
-
The `singular` method converts a string to its singular form. This function currently only supports the English language:
2686
+
The `singular` method converts a string to its singular form. This function supports [any of the languages support by Laravel's pluralizer](/docs/{{version}}/localization#pluralization-language):
-[Using Translation Strings As Keys](#using-translation-strings-as-keys)
@@ -67,6 +68,27 @@ You may use the `currentLocale` and `isLocale` methods on the `App` facade to de
67
68
//
68
69
}
69
70
71
+
<aname="pluralization-language"></a>
72
+
### Pluralization Language
73
+
74
+
You may instruct Laravel's "pluralizer", which is used by Eloquent and other portions of the framework to convert singular strings to plural strings, to use a language other than English. This may be accomplished by invoking the `useLanguage` method within the `boot` method of one of your application's service providers. The pluralizer's currently supported languages are: `french`, `norwegian-bokmal`, `portuguese`, `spanish`, and `turkish`:
75
+
76
+
use Illuminate\Support\Pluralizer;
77
+
78
+
/**
79
+
* Bootstrap any application services.
80
+
*
81
+
* @return void
82
+
*/
83
+
public function boot()
84
+
{
85
+
Pluralizer::useLanguage('spanish');
86
+
87
+
// ...
88
+
}
89
+
90
+
> {note} If you customize the pluralizer's language, you should explicitly define your Eloquent model's [table names](/docs/{{version}}/eloquent#table-names).
0 commit comments