Zend Form中如何将英文错误提示设置为中文错误提示(Zend_Form国际化)

可查看Zend Framework的官方参考手册:Internationalization of Zend_Form

Zend_Form表单验证的错误提示均默认为英文,下面介绍如何将英文错误提示设置为中文。

[php]
// application/Bootstrap.php

protected function _initForm()
{
$translate = new Zend_Translate(
array(
‘adapter’ => ‘csv’,
‘content’ => APPLICATION_PATH.’/configs/translation/error-message.csv’,
‘locale’ => ‘zh_CN’,
‘delimiter’ => ‘,’
)
);
Zend_Form::setDefaultTranslator($translate);
}
[/php]

[php]
// application/configs/translation/error-message.csv

“Value is required and can’t be empty”,”此项不可以为空”
“‘%value%’ has not only alphabetic and digit characters”,”‘%value%’不是字母或数字”
“‘%value%’ is an empty string”,”此项不可以为空”
“‘%value%’ has not only alphabetic characters”,”‘%value%’包含非英文字母的字符”
“isValid”,”错误”
“‘%value%’ must contain between 13 and 19 digits”,”‘%value%’必须是一个13到19位之间的数字”
“Luhn algorithm (mod-10 checksum) failed on ‘%value%'”,”Luhn algorithm (mod-10 checksum) failed on ‘%value%'”
“‘%value%’ is not between ‘%min%’ and ‘%max%’, inclusively”,”‘%value%’ 不在 ‘%min%’ 和 ‘%max%’之间”
“‘%value%’ is not strictly between ‘%min%’ and ‘%max%'”,”‘%value%’ 必须大于 ‘%min%’ ,小于 ‘%max%'”
“‘%value%’ is not of the format YYYY-MM-DD”,”‘%value%’ 必须是类似 YYYY-MM-DD 这样的日期格式”
“‘%value%’ does not appear to be a valid date”,”‘%value%’ 是一个错误的日期”
“‘%value%’ does not fit given date format”,”‘%value%’ 日期格式错误”
“‘%value%’ contains not only digit characters”,”‘%value%’ 不是数字”
“‘%value%’ is not a valid email address in the basic format [email=local-part@hostname]local-part@hostname[/email]”,”这不是一个电子邮件地址”
“‘%hostname%’ is not a valid hostname for email address ‘%value%'”,”这不是一个电子邮件地址”
“‘%hostname%’ does not appear to have a valid MX record for the email address ‘%value%'”,”这不是一个电子邮件地址”
“‘%localPart%’ not matched against dot-atom format”,”这不是一个电子邮件地址”
“‘%localPart%’ not matched against quoted-string format”,”这不是一个电子邮件地址”
“‘%localPart%’ is not a valid local part for email address ‘%value%'”,”这不是一个电子邮件地址”
“‘%value%’ exceeds the allowed length”,”‘%value%’不是一个电子邮件地址”
“‘%value%’ does not appear to be a float”,”‘%value%’不是一个浮点数”
“‘%value%’ is not greater than ‘%min%'”,”输入值必须大于 ‘%min%'”
“‘%value%’ has not only hexadecimal digit characters”,”输入值不是一个十六进制字符串”
“Tokens do not match”,”表单已过期,请重新提交”
“No token was provided to match against”,”表单已过期,请重新提交”
“‘%value%’ was not found in the haystack”,”‘%value%’不在可选范围之内”
“‘%value%’ does not appear to be an integer”,”‘%value%’ 不是一个整数”
“‘%value%’ does not appear to be a valid IP address”,”‘%value%’ 不是一个合法的IP地址”
“‘%value%’ is not less than ‘%max%'”,”输入值必须小于 ‘%max%'”
“‘%value%’ does not match against pattern ‘%pattern%'”,”‘%value%’ 不符合输入规则 ‘%pattern%'”
“‘%value%’ is less than %min% characters long”,”‘%value%’ 字符长度小于 %min% 位”
“‘%value%’ is greater than %max% characters long”,”‘%value%’ 字符长度超过 %max% 位”
“Captcha value is wrong”,”验证码错误”
“The two given tokens do not match”,”请勿直接刷新,表单已过期,请重新提交”
[/php]



2 thoughts to “Zend Form中如何将英文错误提示设置为中文错误提示(Zend_Form国际化)”

发表评论

邮箱地址不会被公开。