多层关键字Url


Multilang Keyword Url

最近我收到了CodeIgniter的一个项目,所有这些对我来说都是全新的。我有一个多语言的网站,URL的结构如下:

http://domain.com/properties/...

基本上,我需要的是当我切换到另一种语言时更改关键字"属性",网站内容已经做到了这一点,但缺少关键字。我一直在寻找路线,以下是我的路线结构:

$route['(:any)/properties/(:any)'] = "(:any)/show/detail/$2";

我正试图制作这个:

$route['(:any)/lang_key('property_lang')/(:any)'] = "(:any)/show/detail/$2";

但我想我做得不对,有人能告诉我该怎么做吗?

我看到的唯一方法是通过数据库。

构建一个如下所示的表:

路线_转换

**********************************
*id |  term   | controller | lang*
**********************************
* 1 | home    |    home    | en  *
* 2 | accueil |    home    | fr  *
                ...
********************************** 

然后在你的routes.php

require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get('routes_translation');
$result = $query->result();
foreach( $result as $row )
{
    $route[$row->term] = $row->controller;
}