php - Zend 翻译 Zend 表单!

标签 php zend-framework forms translation

目前,isEmpty 错误抛出:

    Value is required and can't be empty

我正在像这样加载我的翻译器:

[translation]

adapter = array
content.english["emailNotUnique"] = "Your user already exists"
content.english["Value is required and can't be empty"] = "You must specify your ID"
locale = en

上面的配置根据 zend 翻译规范生成了一个有效的数组,所以:

$this -> form -> setTranslator(new Zend_Translate($this -> getConfig() -> translation));

预期的结果是 isEmpty 错误现在应该显示为

    You must specify your ID

但是我没有得到爱。没有错误,也没有翻译。我正在使用 Zend 1.11.1 和 PHP5.3.5。

最佳答案

我认为问题出在您的 ini 文件中的 english 键上。具体来说,它不应该在那里,因为您实际上作为 content 传递给 Zend_Translate 的是:

    'content' => array(
        'english' => array(
            "emailNotUnique" => 'Your user already exists' ,
            "Value is required and can't be empty" => 'You must specify your ID' 
        )            
    );

它应该是:

    'content' => array(          
            "emailNotUnique" => 'Your user already exists' ,
            "Value is required and can't be empty" => 'You must specify your ID'             
    );

希望这会有所帮助。

关于php - Zend 翻译 Zend 表单!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5065838/

相关文章:

php - 如何使用 WordPress 在 URL 中传递额外的变量

php - 关闭 Apache/PHP 中的传入连接

php - 使用 Zend DB 框架从 MySQL 中只获取一行

javascript - 使用 Javascript 进行表单验证(通过所选选项验证输入文本)

javascript - SEO 和大量用于搜索功能的表单/Javascript 链接

php - 查询多个 WHERE 不工作

javascript - 与 discord bot 通信的 HTML/PHP 网站

unit-testing - 使用 PHPUnit 3.5 测试时出错

php - Zend Framework - Zend_Form 装饰器问题

php - 有没有等同于 PHP 的 $name = $_GET ['name' 的 JQuery 或 JS ]