Skip to content

Commit

Permalink
Merge pull request #376 from allantatter/master
Browse files Browse the repository at this point in the history
Add support for subdirectories as base url
  • Loading branch information
Marc Cámara authored Dec 16, 2016
2 parents 82bc38c + c4206c4 commit 149d552
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Mcamara/LaravelLocalization/LaravelLocalization.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class LaravelLocalization {
*/
protected $request;

/**
* Illuminate url class.
*
* @var \Illuminate\Routing\UrlGenerator
*/
protected $url;

/**
* Illuminate request class.
*
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) )
Expand Down

0 comments on commit 149d552

Please sign in to comment.