基于数据库的数据字典
Requirements ¶
Yii 1.1 or above
Usage ¶
直接加载到controllers中 运行datadict/datadict,生成数据字典; 运行datadict/updatedict,自动更新数据字典;
数据字典可以根据数据库生成data_dict的记录并生成当前应用下的语言翻译文件, 如果你的应用是zh_cn的,就会在protected\messages\zh_cn\models目录下生成与数据表对应的文件,内容与数据字段相对应,
return array(
'Contents'=>'文章',
'ID'=>'编号',
'Cat'=>'分类',
'Title'=>'标题',
'Subhead'=>'短标题',
'Initial'=>'缩写',
'Author'=>'作者',
'Source'=>'来源',
'Source Url'=>'来源url',
'Summary'=>'摘要',
'Content'=>'内容',
'Language'=>'语言',
'Status'=>'状态',
'Insert User'=>'添加用户',
'Insert Time'=>'添加时间',
'Update User'=>'更新用户',
'Update Time'=>'更新时间',
'Tags'=>'标签',
'Redirecturl'=>'redirecturl',
'Thumb'=>'thumb',
'Ishtml'=>'ishtml',
'Publish Time'=>'publish_time',
'Alias'=>'alias',
);
然后可以根据需要通过浏览器或者直接从文件翻译内容。 结合model文件形成翻译
public function attributeLabels()
{
return array(
'id' => Yii::t('models/Content','ID'),
'cat_id' => Yii::t('models/Content','Cat'),
'title' => Yii::t('models/Content','Title'),
'subhead' => Yii::t('models/Content','Subhead'),
'initial' => Yii::t('models/Content','Initial'),
'author' => Yii::t('models/Content','Author'),
'source' => Yii::t('models/Content','Source'),
'source_url' => Yii::t('models/Content','Source Url'),
'redirecturl' => Yii::t('models/Content','Redirecturl'),
'tags' => Yii::t('models/Content','Tags'),
'thumb' => Yii::t('models/Content','Thumb'),
'summary' => Yii::t('models/Content','Summary'),
'content' => Yii::t('models/Content','Content'),
'language' => Yii::t('models/Content','Language'),
'ishtml' => Yii::t('models/Content','Ishtml'),
'file_name' => Yii::t('models/Content','File Name'),
'status' => Yii::t('models/Content','Status'),
'publish_time' => Yii::t('models/Content','Publish Time'),
'insert_user' => Yii::t('models/Content','Insert User'),
'insert_time' => Yii::t('models/Content','Insert Time'),
'update_user' => Yii::t('models/Content','Update User'),
'update_time' => Yii::t('models/Content','Update Time'),
);
}
主要用在后台,修改字段对应的名称就很方便了。
Yii官网在国内实在是时断时续,写的不清楚,见谅!
怎么添加文件下载呀?
请到我的网站下载吧,http://www.chenggang.net/posts/104
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.