统一设置zend_form的验证消息为中文 - ZF Dream

统一设置zend_form的验证消息为中文

阿克 posted @ 2009年8月09日 21:10 in 高人经验 with tags 本地化 Zend_Form Zend Framework php , 3160 阅读

 zend_form表单验证所显示的错误信息都是英文,我把它们整理了一下,只要在form中进行如下设置: 

$languageFile=ROOT_PATH.'/library/Fwcms/language/simpleChinese.php'//自定义文件名和路径
$translate = new Zend_Translate('array',$languageFile, 'zh_CN');
$form->setTranslator($translate);

 然后把以下代码保存为simpleChinese.php,就可以让提示成为中文了: 

<?php
return array(
    "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'=>'Tokens do not match',
    'No token was provided to match against'=>'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% 位"
);
?>

来源:http://bbs.zendchina.net/viewthread.php?tid=318


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee