0
我需要使用url中的語言構建多語言站點,如http://example.org/jp/users/login,但我想避免必須將語言編碼到現場。我有效地有這樣的路由:如何在Cake 3.0中的鏈接的URL中包含語言片段
$routes->connect(
'/:lang/:controller/:action/*',
['prefix' => 'customer'],
['routeClass' => 'DashedRoute', 'lang' => '[a-z]{2}']
);
我要爲鏈接做到這一點:
$this->Html->link(__('List Users'), ['lang' => 'en', 'controller' => 'users', 'action' => 'index']);
有沒有什麼辦法讓郎可以自動添加,我只能這樣做了鏈接,而不是?
$this->Html->link(__('List Users'), ['controller' => 'users', 'action' => 'index']);
很好,謝謝! –
您可以嘗試使用我的[i18n](https://github.com/ADmad/cakephp-i18n)插件,它提供了自定義路線類,以簡化與語言前綴/片段的連接路線。 – ADmad