2016-11-11 56 views
7

我有不同的区域设置多条路线:Zend的翻译航线

例子:

路线对/日

$routes['industry'] = array(
    'route' => 'branche/:type', 
    'defaults' => array(
     'module' => 'default', 
     'controller' => 'index', 
     'action' => 'branche', 
     'type' => 'automobil' 
    ), 
    'reqs' => array(
     'type' => '(automobil|textil)' 
    ) 
); 

路线为/ EN

$routes['industry'] = array(
    'route' => 'industry/:type', 
    'defaults' => array(
     'module' => 'default', 
     'controller' => 'index', 
     'action' => 'branche', 
     'type' => 'car' 
    ), 
    'reqs' => array(
     'type' => '(car|textile)' 
    ) 
); 

它可能以某种方式在这种情况下只有一条路线而不是2条?

注意不仅仅是路线的改变,还有需求和默认类型的类型。

回答

1

我看到了两个不同的路线有 通常情况下,国际化是在页面上,但不是在URL

让我清楚,你把你的网址,并用URL中的参数,你知道该页面的语言所以

$routes['industry'] = array(
    'route' => 'industry/:lang/:type', 
    'defaults' => array(
     'module' => 'default', 
     'controller' => 'index', 
     'action' => 'branche', 
     'type' => 'car', 
     'lang' => 'en' 
    ), 
    'reqs' => array(
     'lang' => '(en|de)', 
     'type' => '(car|textile)' 
    ) 
); 

,并根据参数郎您在树枝或PHTML或HTML

另一种方式显示正确的消息,这样做改变网址是:

$routes['industry'] = array(
    'route' => ':industry/:type', 
    'defaults' => array(
     'module' => 'default', 
     'controller' => 'index', 
     'action' => 'branche', 
     'type' => 'car', 
     'industry' => 'industry' 
    ), 
    'reqs' => array(
     'industry' => '(industry|branche)', 
     'type' => '(car|textile)' 
    ) 
); 
+0

这不能解决URL翻译。将永远是“行业”的URL而不是“分支”。 – costa

+0

是否必须更改网址?在这种情况下,你应该做两条路线。根据我的经验,您始终将您的网址保存为一种语言,并根据语言更改内容,但当然每个实际情况都不同并且有不同的需求。如果您需要更改网址,您必须创建两个路径或行业|分支是一个参数。我编辑解决方案2的答案 – Emiliano