From 79f92e57dfa6b0c49b92c310432080ad5ca51c2c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 9 Aug 2012 22:42:03 -0500 Subject: [PATCH] defer language support in URIs to version 4. --- application/config/application.php | 13 --------- laravel/laravel.php | 42 ++---------------------------- laravel/url.php | 8 ------ 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/application/config/application.php b/application/config/application.php index 60735a60..525227c2 100755 --- a/application/config/application.php +++ b/application/config/application.php @@ -94,19 +94,6 @@ 'language' => 'en', - /* - |-------------------------------------------------------------------------- - | Supported Languages - |-------------------------------------------------------------------------- - | - | These languages may also be supported by your application. If a request - | enters your application with a URI beginning with one of these values - | the default language will automatically be set to that language. - | - */ - - 'languages' => array(), - /* |-------------------------------------------------------------------------- | SSL Link Generation diff --git a/laravel/laravel.php b/laravel/laravel.php index 1f908eed..2772e323 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -107,46 +107,6 @@ return Event::first('404'); }); -/* -|-------------------------------------------------------------------------- -| Gather The URI And Locales -|-------------------------------------------------------------------------- -| -| When routing, we'll need to grab the URI and the supported locales for -| the route so we can properly set the language and route the request -| to the proper end-point in the application. -| -*/ - -$uri = URI::current(); - -$locales = Config::get('application.languages', array()); - -$locales[] = Config::get('application.language'); - -/* -|-------------------------------------------------------------------------- -| Set The Locale Based On Route -|-------------------------------------------------------------------------- -| -| If the URI starts with one of the supported languages, we will set -| the default language to match that URI segment and shorten the -| URI we'll pass to the router to not include the lang segment. -| -*/ - -foreach ($locales as $locale) -{ - if (starts_with($uri, $locale)) - { - Config::set('application.language', $locale); - - $uri = trim(substr($uri, strlen($locale)), '/'); break; - } -} - -if ($uri === '') $uri = '/'; - /* |-------------------------------------------------------------------------- | Route The Incoming Request @@ -158,6 +118,8 @@ | */ +$uri = URI::current(); + Request::$route = Routing\Router::route(Request::method(), $uri); $response = Request::$route->call(); diff --git a/laravel/url.php b/laravel/url.php index 3ad6a3e2..2b97128c 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -107,14 +107,6 @@ public static function to($url = '', $https = null) $root = static::base().'/'.Config::get('application.index'); - // If multiple languages are being supported via URIs, we will append current - // language to the URI so all redirects and URLs generated include the - // current language so it is not lost on further requests. - if (count(Config::get('application.languages')) > 0) - { - $root .= '/'.Config::get('application.language'); - } - // Since SSL is not often used while developing the application, we allow the // developer to disable SSL on all framework generated links to make it more // convenient to work with the site while developing locally.