4
我的應用程序翻譯我想用一個語言結構,例如:路由Zend框架2語言的網址
- site.com(英文)
- site.com/de/(德國)
- site.com/fr/(法國)
- site.com/nl/(荷蘭)
等。
我可以使用Literal中的路由器選項輕鬆完成此操作,但我希望排除我不支持的語言,例如, site.com/it/如果它不被支持我想要一個404。我試圖用正則表達式(添加支持的語言)來解決這個問題,但是某些東西(我不知道)出錯了。
在此先感謝!
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'language' => array(
'type' => 'Regex',
'options' => array(
'regex' => '/(?<lang>(de|fr|nl))?',
'defaults' => array(
'lang' => 'en', //default
),
'spec' => '/%lang%',
),
),
),
),
),
),
的感謝!我拿了你的第二個選擇:) – directory