duanjiaolia97750
2015-01-16 15:57
浏览 49
已采纳

在Codeigniter的form_validation中使用语言文件

I´m validating a form with the codeigniter form validation class and an own form_validation file in the configuration. Additionally I´m using the language class for translation. That works perfect in view and controller but I need to get the translation also in the config/form_validation.php.

Has anybody an idea how I can do that?

Excerpt of the config/form_validation.php

$config = array(

/**
 * Login form
 */
'auth/login' => array(
    array(
        'field' => 'email',
        'label' => 'E-Mail address', <--- HERE I´D LIKE TO USE THE TRANSLATIONS
        'rules' => 'trim|required|xss_clean|valid_email'
    ),
    array(
        'field' => 'password',
        'label' => 'Password',
        'rules' => 'trim|required|xss_clean'
    )
),
.....

Thanks for your ideas, best Michael

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongpo5239 2015-01-16 16:14
    已采纳

    You can use the 'lang' prefix like..

    'auth/login' => array(
      array(
        'field' => 'email',
        'label' => 'lang:email_address_label',
        'rules' => 'trim|required|xss_clean|valid_email'
      )
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题