繁体   English   中英

Zend翻译了路线

[英]Zend translated routes

我有不同的语言环境的多个路由:

例:

路线为/ de

$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条路线?

注意不仅是更改的路由,还有reqs上的类型和默认类型。

我看到两条不同的路线通常国际化在页面上但不在网址上

让我说清楚,你保留你的网址和网址中的参数,你知道页面的语言

$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)'
    )
);

并且根据参数lang,您可以在twig或phtml或html上显示正确的消息

另一种更改URL的方法是:

$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)'
    )
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM