@@ -267,18 +267,15 @@ Not even when you create your custom `errors.404` view.
267
267
Therefor, the locale can't be set to match the requested URL automatically via middleware.
268
268
269
269
To enable localized ` 404 ` pages, you need to register a ` fallback ` route
270
- and make sure it has the ` SetLocale ` middleware and a name of ` 404 ` .
270
+ and make sure it has the ` SetLocale ` middleware.
271
271
This is basically a catch all route that will trigger for all non existing URL's.
272
272
273
273
``` php
274
274
Route::fallback(function () {
275
275
return response()->view('errors.404', [], 404);
276
- })->name('404')-> middleware(\CodeZero\LocalizedRoutes\Middleware\SetLocale::class);
276
+ })->middleware(\CodeZero\LocalizedRoutes\Middleware\SetLocale::class);
277
277
```
278
278
279
- > Because you might use a ` fallback ` route for another purpose,
280
- this package will only consider it to be a ` 404 ` if you name the route ` 404 ` .
281
-
282
279
Another thing to keep in mind is that a ` fallback ` route returns a ` 200 ` status by default.
283
280
So to make it a real ` 404 ` you need to return a ` 404 ` response yourself.
284
281
@@ -290,6 +287,8 @@ Fallback routes will not be triggered when:
290
287
291
288
Because those routes are in fact registered, the ` 404 ` page will have the correct ` App::getLocale() ` set.
292
289
290
+ [ Here is a good read about fallback routes] ( https://themsaid.com/laravel-55-better-404-response-20170921 ) .
291
+
293
292
### 🚕 Generate Route URL's
294
293
295
294
You can get the URL of your named routes as usual, using the ` route() ` helper.
0 commit comments