简体   繁体   English

Zend翻译了路线

[英]Zend translated routes

I have multiple routes for different locales: 我有不同的语言环境的多个路由:

Example: 例:

Route for /de 路线为/ de

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

Route for /en 路线为/ en

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

Its possible somehow to have just one route instead of 2 on this case? 在这种情况下,它可能以某种方式只有一条路线而不是2条路线?

Note is not just the route which changes, also the type on the reqs and the default type. 注意不仅是更改的路由,还有reqs上的类型和默认类型。

I see two different routes there Usually the internationalisation is on the page but not on the url 我看到两条不同的路线通常国际化在页面上但不在网址上

Let me be clear, you keep your url and with a parameter in the url you know the language of the page so 让我说清楚,你保留你的网址和网址中的参数,你知道页面的语言

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

and depending of the parameter lang you display the correct message on your twig or phtml or html 并且根据参数lang,您可以在twig或phtml或html上显示正确的消息

Another way to do this changing the url is: 另一种更改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