dpj0015 2010-12-29 00:35
浏览 36
已采纳

cakepp由网址选择语言

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

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

  • 写回答

1条回答 默认 最新

  • douyan1921 2010-12-29 02:36
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度