/**
  * @uses ModelAsController::getNestedController()
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->request = $request;
     $this->setDataModel($model);
     $this->pushCurrent();
     //Get the local from the language param
     if (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL')) {
         if (Config::inst()->get('MultilingualRootURLController', 'UseDashLocale')) {
             //Language is missing a dash 404
             if (strpos($request->param('Language'), '-') === false) {
                 //Locale not found 404
                 if ($response = ErrorPage::response_for(404)) {
                     return $response;
                 } else {
                     $this->httpError(404, 'The requested page could not be found.');
                 }
                 return $this->response;
             }
             $locale = explode('-', $request->param('Language'));
             $locale[1] = strtoupper($locale[1]);
             //Make sure that the language is all lowercase
             if ($request->param('Language') == implode('-', $locale)) {
                 //Locale not found 404
                 if ($response = ErrorPage::response_for(404)) {
                     return $response;
                 } else {
                     $this->httpError(404, 'The requested page could not be found.');
                 }
                 return $this->response;
             }
             $locale = implode('_', $locale);
         } else {
             $locale = $request->param('Language');
         }
     } else {
         if (strpos($request->param('Language'), '_') !== false) {
             //Locale not found 404
             if ($response = ErrorPage::response_for(404)) {
                 return $response;
             } else {
                 $this->httpError(404, 'The requested page could not be found.');
             }
             return $this->response;
         } else {
             $locale = i18n::get_locale_from_lang($request->param('Language'));
         }
     }
     if (in_array($locale, Translatable::get_allowed_locales())) {
         //Set the current locale and remember it
         Cookie::set('language', $request->param('Language'));
         Translatable::set_current_locale($locale);
         i18n::set_locale($locale);
     } else {
         //Locale not found 404
         if ($response = ErrorPage::response_for(404)) {
             return $response;
         } else {
             $this->httpError(404, 'The requested page could not be found.');
         }
         return $this->response;
     }
     //Handle the home page for the language
     $urlSegment = $request->param('URLSegment');
     if (empty($urlSegment)) {
         $controller = new MultilingualRootURLController();
         $response = $controller->handleRequest($request, $model);
         $this->popCurrent();
         return $response;
     }
     //Normal page request so handle that
     $response = parent::handleRequest($request, $model);
     $this->popCurrent();
     return $response;
 }