开发者

cakephp choosing language by url

what I am trying to achieve is described here http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/ but I can not get it working.

The router configurations looks like this:

Router::connect('/registered/:language/:controller/:action/*',
 array('prefix' => 'registered', 'registered' => true, 'layout'=> 'registered'),
 array('language' => '[a-z]{3}'));

butw when I try to go to www.example.com/registered/cze/packages I get:

Error: CzeController could not be found.

I am using cake 1.3, not 1.2 as the author, that may be the problem, but what do I need to change in order for this to work?

Edit:

$this->Session->write('Config.language','cze开发者_StackOverflow中文版');

This code works and when used in the controller changes the language of the site, but I need to get it working according to the URL


The URL www.example.com/registered/cze/packages does not match the route /registered/:language/:controller/:action/*, since the :action segment is empty. Therefore, the URL falls through to the standard route, where registered is recognized as the prefix and cze as the controller.

You'll need to create a "shorter" /registered/:language/:controller route as well to catch "abbreviated" URLs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜