If you have a configurable list in table(t_credit_types) like:
1->Gold
2->Silver
3->Bronze
and you have get all data from that table by a find.
Now instead of using the english string in a selection box, you are required to display localized strings.
There are two ways of localizing the selection box in cakephp.
Solution 1. provide localized strings in db table
t_credits_types_lang
(credit_type_id+lang+description)
1->zh_CN->黄金
2->zh_CN->白银
3->zh_CN->黄铜
now you can find all localized strings from this additional table by certain language code.
$types = $this->CreditType->find('list', array(
'conditions' => array('lang'=>'zh_CN'),
'fields' => array('type','description'),
)); echo $form->input('type', array('type' => 'select', 'options' => $types));
Solution 2. localize these strings in view template
say, if you retreived all types by below sql:
$types = $this->CreditType->find('list', array(
'fields' => array('type','description'),
));
in view template, what we need to do is simply as:
$lc_types = array();
foreach($types as $key=>$value) {
$lc_types[$key] = __($value, true);
}
echo $form->input('type', array('type' => 'select', 'options' => $lc_types));
iefreer
分享到:
相关推荐
Learn CakePHP: With Unit Testing by Rādhārādhya Dāsa 2016 | ISBN: 1484212134 | English | 114 pages | EPUB | 1 MB Accelerate your development of PHP applications using the popular CakePHP web ...
This is a simple demo of some of the AJAX helpers now available in CAKE. These helpers are directly modeled on Ruby On Rails. In fact, they were shamelessly ported from rails almost verbatim....
是PHP的快速开发框架,它使用诸如联合数据映射,前端控制器和MVC之类的众所周知的设计模式。 我们的主要目标是提供一个结构化的框架,该框架使所有级别PHP用户都可以快速开发健壮的Web应用程序,而不会损失灵活性。 ...
Lead you from a basic setup of CakePHP to building a couple applications that will highlight CakePHPs functionality and capabilities without delving too deeply into the PHP language, but rather ...
cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架
CakePHP 4.0.0 具有更新的应用程序骨架设计,带有简化的 API,使您的开发和应用程序更快。 虽然 4.0 包含许多重大更改,但我们准备了详尽的迁移指南,涵盖所有已弃用和删除的功能以及突出显示闪亮的新功能。 CakeDC...
CakePHP: 快速的PHP开发框架官方库
我们的主要目标是提供一个结构化的框架,该框架使enabl CakePHP是一个PHP的快速开发框架,它使用诸如关联数据映射,前端控制器和MVC之类的众所周知的设计模式。 我们的主要目标是提供一个结构化的框架,该框架使所有...
为 CakePHP 2 选择的助手 ChosenHelper是集成HarvestHQ一类CakePHP中2.检查选择框了HarvestHQ的的文档和使用。 变更日志 现已可用。 仔细检查以确保您不会永久升级。 例如:最新版本 (2.1.0) 包括与 CakePHP 2.0.x ...
课程-cakephp 蛋糕PHP 使用 CakePHP 框架的 Web 应用程序开发课程
CakePHP 语言环境 该插件允许您的用户输入本地化数据(如日期和小数),同时保持数据库级别的一致性。 它还包含一个 Helper 以用户语言环境格式输出非本地化数据。 一些静态库以捆绑包形式提供,并由 Helper 和 ...
join ‘other model’ 来指定具体的关联模型进行自定义查询 如果不需要关联数据的情况就不使用join方法 这样就避免了上面问题的产生 2:cakephp中虽然对模型的操作方法中并没有提供像上面提到的连贯方法 但是cake...
CakePHP 一个开源PHP web 开发框架,PHPMVC结构框架,易与开发,是PHP技术人员的开发好的选择之一!
docker-cakephp:示例Dockerfile,用于在Docker容器中部署CakePHP应用程序,能够通过基于数据库的会话连接到远程数据库
cakephp 框架书籍 英文版
看到论坛好多人寻找cakephp 现在将本人的分享给各位大侠
打包下载,里面有CakePHP的框架源码,下载后可直接使用,版本是1.1的,稳定版;CakePHP的分页组件源码;CakePHP的中文及英文教程,CHM格式;CakePHP的中文打印版教程,WORD格式,下载后可直接打印,方便的;CakePHP...
CakePHP CakePHP是PHP的快速开发框架,它使用Active Record,关联数据映射,Front Controller和MVC等众所周知的设计模式。 我们的主要目标是提供一个结构化的框架,该框架使所有级别PHP用户都可以快速开发健壮的Web...
在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该项目...