Skip to content

Commit f3d46c4

Browse files
committed
Document full URI translation
1 parent 4cc40c3 commit f3d46c4

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,19 @@ resources
481481
└── routes.php
482482
```
483483

484-
In these files, add a translation for each segment.
484+
In these files, add a translation for each segment, or for the full URI.
485+
486+
If an exact match is found, that will be returned.
487+
Otherwise, each segment will be translated separately.
488+
If a translation is not found, the original segment is used.
485489

486490
```php
487491
// lang/nl/routes.php
488492
return [
489-
'about' => 'over',
490-
'us' => 'ons',
493+
'glass' => 'glas',
494+
'products' => 'producten',
495+
'materials' => 'materiaal',
496+
'materials/glass' => 'producten/glazen'
491497
];
492498
```
493499

@@ -496,21 +502,24 @@ Now you can use our `Lang::uri()` macro during route registration:
496502
```php
497503
Route::localized(function () {
498504

499-
Route::get(Lang::uri('about/us'), AboutController::class.'@index')
500-
->name('about.us');
505+
Route::get(Lang::uri('products/glass'), ProductsController::class.'@index')
506+
->name('products.glass');
507+
508+
Route::get(Lang::uri('materials/glass'), MaterialsController::class.'@index')
509+
->name('materials.glass');
501510

502511
});
503512
```
504513

505-
Note that in order to find a translated version of a route, you will need to give your routes a name.
506-
If you don't name your routes, only the parameters (model route keys) will be translated, not the "hard-coded" slugs.
507-
508514
The above will generate:
509515

510-
- /en/about/us
511-
- /nl/over/ons
516+
- /en/products/glass
517+
- /nl/producten/glass
518+
- /en/materials/glass
519+
- /nl/materials/glazen
512520

513-
> If a translation is not found, the original segment is used.
521+
Note that in order to find a translated version of a route, you will need to give your routes a name.
522+
If you don't name your routes, only the parameters (model route keys) will be translated, not the "hard-coded" slugs.
514523

515524
## 🚏 Route Parameters
516525

0 commit comments

Comments
 (0)