2012-04-25 89 views
0

由於我正在嚮應用程序添加多語言支持,並且在我的routes.php中遇到了某些路由已停止工作的問題。在routes.php中使用多種語言

似乎任何一個段的作品,任何有兩個或更多的東西沒有。

任何幫助如何解決這個問題將不勝感激。

routes.php文件摘錄:

// URI like '/en/about' -> use controller 'about' 
$route['^(en|br)/(.+)$'] = "$2"; 
$route['dashboard'] = 'dashboard'; //THIS WORKS 
$route['profile'] = 'profile/profile_list'; 
$route['profile_list/page'] = 'profile/profile_list'; //THIS DOESN'T 
$route['profile_list/page/(:any)'] = 'profile/profile_list/$1'; 
$route['profile/update'] = 'profile/update'; 
$route['profile/(:any)'] = 'profile/$1'; 
$route['default_controller'] = 'landing'; 
// '/en', '/de', '/fr' and '/nl' URIs -> use default controller 
$route['^(en|br)$'] = $route['default_controller']; 
+0

So/en/profile_list/page和/ profile_list/page都不起作用? – minboost 2012-04-25 06:15:26

+0

是的,它必須處理url網段的數量。我想出了一個解決方案,我將發佈。 – jsuissa 2012-04-25 14:39:09

回答

1

想通了這個問題的答案與信息:Codeigniter forum

只是需要加入這個變量,其中包括對任意兩個字母的語言代碼我的URL段用途:

$prepended_lang = "(?:[a-zA-Z]{2}/)?"; 

然後修改相應的路徑:

$route[$prepended_lang.'logout'] = 'login/logout';