Implement URI language detection
This commit is contained in:
@@ -41,6 +41,9 @@
|
|||||||
$route['default_controller'] = "auth";
|
$route['default_controller'] = "auth";
|
||||||
$route['404_override'] = '';
|
$route['404_override'] = '';
|
||||||
|
|
||||||
|
$route['(\w{2})/(.*)'] = '$2';
|
||||||
|
$route['(\w{2})'] = $route['default_controller'];
|
||||||
|
|
||||||
|
|
||||||
/* End of file routes.php */
|
/* End of file routes.php */
|
||||||
/* Location: ./application/config/routes.php */
|
/* Location: ./application/config/routes.php */
|
||||||
@@ -128,9 +128,8 @@ class Lang_detect {
|
|||||||
for ($i = $this->CI->uri->total_segments(); $i > 0; $i--) {
|
for ($i = $this->CI->uri->total_segments(); $i > 0; $i--) {
|
||||||
$segment = $this->CI->uri->segment($i);
|
$segment = $this->CI->uri->segment($i);
|
||||||
// the uri segment with the language code has the prefix 'l_'
|
// the uri segment with the language code has the prefix 'l_'
|
||||||
if (!empty($segment) && (strpos($segment, 'l_') === 0)) {
|
if (strlen($segment) == 2 && array_key_exists($segment, $this->languages)) {
|
||||||
// extract the language code
|
return $segment;
|
||||||
return substr($segment, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user