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
Check out the [Laravel docs](https://laravel.com/docs/urls#signed-urls) for more info on signed routes.
443
443
444
-
### 🌎 Translate Routes
444
+
### 🌎 URI Translations
445
445
446
-
If you want to translate the segments of your URI's, create a `routes.php` language file for each locale you [configured](#%EF%B8%8F-supported-locales):
446
+
This package includes [codezero/laravel-uri-translator](https://github.com/codezero-be/laravel-uri-translator), which registers a `Lang::uri()` macro that enables you to translate individual, hard-coded URI slugs.
447
+
Route parameters will not be translated by this macro.
447
448
448
-
```
449
-
resources
450
-
└── lang
451
-
├── en
452
-
│ └── routes.php
453
-
└── nl
454
-
└── routes.php
455
-
```
456
-
457
-
In these files, add a translation for each segment, or for the full URI.
458
-
459
-
If an exact match is found, that will be returned.
460
-
Otherwise, each segment will be translated separately.
461
-
If a translation is not found, the original segment is used.
462
-
463
-
```php
464
-
// lang/nl/routes.php
465
-
return [
466
-
'glass' => 'glas',
467
-
'products' => 'producten',
468
-
'materials' => 'materiaal',
469
-
'materials/glass' => 'materiaal/glazen'
470
-
];
471
-
```
472
-
473
-
Now you can use our `Lang::uri()` macro during route registration:
Routes with translated URIs need to have a name in order to generate localized versions of it using the `route()` helper or the `Route::localizedUrl()` macro.
450
+
Because these routes have different slugs depending on the locale, the route name is the only thing that links them together.
483
451
484
-
});
485
-
```
486
-
487
-
The above will generate:
488
-
489
-
- /en/products/glass
490
-
- /nl/producten/glass
491
-
- /en/materials/glass
492
-
- /nl/materiaal/glazen
493
-
494
-
If you need to get a translation from a package,
495
-
you can pass an optional translation namespace as a third parameter to `Lang::uri()`:
0 commit comments