CodeIgniter Forums
$this->validation->set_message simple issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->validation->set_message simple issue (/showthread.php?tid=9036)



$this->validation->set_message simple issue - El Forum - 06-09-2008

[eluser]EEssam[/eluser]
Hello,

The app I'm coding is not in English, so I'm trying to do the following:

// username
$rules['username'] = "required";
$this->validation->set_message($rules['username'], 'username is a required field in my language');

// password
$rules['password'] = "required";
$this->validation->set_message($rules['password'], 'password is a required field in my language');

The problem is I'm getting "password is a required field in my language" for both fields Sad

For instance, I just can't write:

- Username est un champ obligatoire (in french), it should be something like:

- Le nom d'utilisateur est un champ obligatoire

How can I overcome this problem?

Your help would be greatly appreciated.


$this->validation->set_message simple issue - El Forum - 06-09-2008

[eluser]xwero[/eluser]
Why not set the default language to french, that is the easiest solution. There is a french languagepack available on the wiki.


$this->validation->set_message simple issue - El Forum - 06-09-2008

[eluser]EEssam[/eluser]
How can I get "Le nom d’utilisateur est un champ obligatoire" instead of "Username est un champ obligatoire" in doing that?


$this->validation->set_message simple issue - El Forum - 06-09-2008

[eluser]xwero[/eluser]
Then you have to use the set_fields method
Code:
$fields['username'] = "le nom d'utilisateur";
$this->validation->set_fields($fields);



$this->validation->set_message simple issue - El Forum - 06-09-2008

[eluser]EEssam[/eluser]
Thank you very much that worked perfectly. I knew there was a clever solution for this Smile