CodeIgniter Forums
change language in validation error message. How to get it work? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: change language in validation error message. How to get it work? (/thread-25522.html)



change language in validation error message. How to get it work? - El Forum - 12-15-2009

[eluser]runrun[/eluser]
I followed every steps in user guide but can't get it right, hope you can help me.
I'm making a newsletter subscribing, user will provide email, if fail validation, they see error message in Vietnamese instead of English. I don't know what steps missed out.

My controller:

Code:
class Home extends Controller {
    function Home()
    {
        parent::Controller();
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<span class="error">', '</span>');
        $this->lang->load('viet_validation','vietnamese');
    }

    function index()
    {
        $data['submit_success'] = '';
        $this->form_validation->set_rules('email','lang:Email','required|trim|valid_email');
        
        if($this->form_validation->run() == FALSE)
        {
            $this->load->view('home_view.php', $data);
        }
        else
        {
            $input = array('email'=> $this->input->post('email'));
            $this->db->insert('mail_list', $input);
            $data['submit_success'] = 'Đang kí hoàn tất';
            $this->load->view('home_view.php', $data);
        }
        
    }
}

My view:
Quote: &lt;form class="sub_form" method="post" action="&lt;?=site_url('home')?&gt;"&gt;

&lt;input type="text" name="email" value="email" class="submail" /&gt;
&lt;input type="submit" value="submit" /&gt;&lt;br />
&lt;?=form_error('email')?&gt;
&lt;?=$submit_success?&gt;
&lt;/form&gt;

My customized error message in vietnamese language file is located at
Code:
system/application/language/vietnamese/viet_validation_lang.php

here is how it look like
Code:
$lang['required']             = "Cần phải cung cấp %s.";
$lang['valid_email']        = "%s không hợp lệ.";