Is there anyway to translate CodeIgniter’s form validation error messages without touching to system files?
Is there anyway to translate CodeIgniter’s form validation error messages without touching to system
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are talking about actually translating to another language, this can be done by setting the config value
$config['language']to the language you want. If you don’t want to change the actual config.php file you can do it through the use of the Config object’sset_item()function like this:See: CodeIgniter Doc for the Config Class
This assumes that you have a spanish directory in your
languagedirectory with at least theform_validation_lang.phpfile.However, if you are just wanting to create custom messages for the Form_validation object, you can copy the
form_validation_lang.phpfile from thesystem\languagedirectory and move it to theapplication\languagedirectory. You can now edit the new language file to make it reflect any different messages you want. You can also revert back to the default messages easily by removing the file from theapplication/languagedirectory.Another way to do it, if you don’t want to touch even the
languagefiles is to manually override the messages. You can do that through theForm_validationlibrary object like so:See: CodeIgniter Doc for the Form Validation Class