CodeIgniter Forums
Localizing the error messages for rules in form_validation library - 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: Localizing the error messages for rules in form_validation library (/thread-25931.html)



Localizing the error messages for rules in form_validation library - El Forum - 12-31-2009

[eluser]chamila[/eluser]
I am using the form_validation library, and I want the error messages that are displayed for rules like required, min_value to be dynamically selected from the language file according to the locale.

I can display the localized strings for the rest of the page by using template parser library. But I can't figure out the error messages.

I tried the following too, but it doesn't work. Gives out a lot of errors (required_error is the line in the lang file).

Code:
$this->form_validation->set_message("required", $this->lang->line("required_error"));

Can anyone help me out with this?

Thank you!


Localizing the error messages for rules in form_validation library - El Forum - 12-31-2009

[eluser]chamila[/eluser]
I found a solution for this.

Use the helper provided here.

http://maestric.com/doc/php/codeigniter_i18n

The extra work includes putting entries in the My_language.php, routes.php and writing the language file.

If you come across any strange characters check the charset attribute of the html header to be utf-8.