Skip to content

Commit

Permalink
fix : getting localized of current route
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Mar 7, 2022
1 parent b2f2bc9 commit b0f33ad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Classes/Localization.php
Expand Up @@ -394,7 +394,7 @@ public function route(string $key, $params = [])
return route($key, $params);

$route = Route::getRoutes()->getByName($key);

if (substr($route->getPrefix(), 0, 9) != '{locale?}')
$route->prefix('/{locale?}');

Expand All @@ -420,12 +420,15 @@ public function unLocalizedRoute(string $key, array $params = [])
}

/**
* Get Localized route-url
* Get Localized route.
*
* @return string
*/
public function currentUrl()
public function current()
{
return $this->route(Route::current()->getName(), Route::current()->parameters());
if (!($name = Route::current()->getName()))
throw new Exception('You should set name for that route.');

return $this->route($name, Route::current()->parameters());
}
}

0 comments on commit b0f33ad

Please sign in to comment.