Skip to content

Commit 1617291

Browse files
authored
Attempt to translate full uri + link fixed in README (#50)
1 parent af695ff commit 1617291

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ Check out the [Laravel docs](https://laravel.com/docs/urls#signed-urls) for more
455455

456456
### 🌎 Translate Routes
457457

458-
If you want to translate the segments of your URI's, create a `routes.php` language file for each locale you [configured](#configure-supported-locales):
458+
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):
459459

460460
```
461461
resources

src/Macros/UriTranslationMacro.php

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class UriTranslationMacro
1616
public static function register()
1717
{
1818
Lang::macro('uri', function ($uri, $locale = null) {
19+
20+
// Attempt to translate full uri.
21+
if (!Str::contains($uri, '{') && Lang::has("routes.$uri", $locale)) {
22+
return Lang::get("routes.$uri", [], $locale);
23+
}
24+
1925
// Split the URI into a Collection of segments.
2026
$segments = new Collection(explode('/', trim($uri, '/')));
2127

0 commit comments

Comments
 (0)