From 2ee4d42d7cad7a6b4bc8702cb2e13c6f1f483539 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Fri, 22 Apr 2011 02:38:25 +0200 Subject: [PATCH] Implement URI language detection --- application/config/routes.php | 3 +++ application/libraries/Lang_detect.php | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/config/routes.php b/application/config/routes.php index 47a4a68..08648da 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -41,6 +41,9 @@ $route['default_controller'] = "auth"; $route['404_override'] = ''; +$route['(\w{2})/(.*)'] = '$2'; +$route['(\w{2})'] = $route['default_controller']; + /* End of file routes.php */ /* Location: ./application/config/routes.php */ \ No newline at end of file diff --git a/application/libraries/Lang_detect.php b/application/libraries/Lang_detect.php index 4a9563f..7f2b3ae 100644 --- a/application/libraries/Lang_detect.php +++ b/application/libraries/Lang_detect.php @@ -128,9 +128,8 @@ class Lang_detect { for ($i = $this->CI->uri->total_segments(); $i > 0; $i--) { $segment = $this->CI->uri->segment($i); // the uri segment with the language code has the prefix 'l_' - if (!empty($segment) && (strpos($segment, 'l_') === 0)) { - // extract the language code - return substr($segment, 2); + if (strlen($segment) == 2 && array_key_exists($segment, $this->languages)) { + return $segment; } } return false;