摘要: 好像网上一直没有比较详细的中文资料来讲述如何使用cakephp来实现i18n。正好昨天被逼无奈的将代码中的提示中文化了一把,略有心得,简而志之。中文化cakephp有如下几步:1,在代码中使用__()函数。在需要进行中文化的地方使用__()函数,如下所示:__('This is the string i need to translate', true);将第2个参数置为ture,这样如果有相对应的翻译词条的话那么翻译过的词条将输出,否则会输出未翻译的词条。2,执行i18n task如果你的代码中存在__()函数的话,你就可以执行i18n task来进行代码扫描了。i18n t 阅读全文
posted @ 2011-07-17 21:58 乙醇 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 原本以为要自己写helper去截取中文字符串,没想到cakephp的Text helper类中已经提供了truncate方法。下面是truncate方法的原型。truncatetruncate(string $text, int $length=100, array $options)Cuts a string to the $length and adds a suffix with ‘ending’ if the text is longer than $length. If ‘exact’ is passed as false, the truncation will occur aft 阅读全文
posted @ 2011-07-17 20:59 乙醇 阅读(597) 评论(0) 推荐(0) 编辑

友情链接 虫师的blog  测试教程网  重定向科技  省略