【发布时间】:2015-10-08 19:10:01
【问题描述】:
我需要建立一个多语言网站,网址中的语言像这样http://example.org/jp/users/login,但我想避免将语言编码到网站上的每个链接中。我实际上有这个路由:
$routes->connect(
'/:lang/:controller/:action/*',
['prefix' => 'customer'],
['routeClass' => 'DashedRoute', 'lang' => '[a-z]{2}']
);
我必须为链接这样做:
$this->Html->link(__('List Users'), ['lang' => 'en', 'controller' => 'users', 'action' => 'index']);
有什么方法可以自动添加 lang 而我可以只为链接执行此操作?
$this->Html->link(__('List Users'), ['controller' => 'users', 'action' => 'index']);
【问题讨论】:
标签: cakephp routing routes cakephp-3.0