diff --git a/src/Mcamara/LaravelLocalization/LaravelLocalization.php b/src/Mcamara/LaravelLocalization/LaravelLocalization.php index a5ac52e..a3f3984 100644 --- a/src/Mcamara/LaravelLocalization/LaravelLocalization.php +++ b/src/Mcamara/LaravelLocalization/LaravelLocalization.php @@ -47,6 +47,13 @@ class LaravelLocalization { */ protected $request; + /** + * Illuminate url class. + * + * @var \Illuminate\Routing\UrlGenerator + */ + protected $url; + /** * Illuminate request class. * @@ -109,6 +116,7 @@ public function __construct() $this->translator = $this->app[ 'translator' ]; $this->router = $this->app[ 'router' ]; $this->request = $this->app[ 'request' ]; + $this->url = $this->app[ 'url' ]; // set default locale $this->defaultLocale = $this->configRepository->get('app.locale'); @@ -240,6 +248,9 @@ public function getLocalizedURL( $locale = null, $url = null, $attributes = arra $url = $this->request->fullUrl(); + } else + { + $url = $this->url->to($url); } if ( $locale && $translatedRoute = $this->findTranslatedRouteByUrl($url, $attributes, $this->currentLocale) )