Unable to load the requested language file: language/en/form_validation_lang.php

I am using codeigniter 2.1.4

In that I am using form_validation library for form validation.

When I try to run that function I get following error

Unable to load the requested language file: language/en/form_validation_lang.php

I have scanned all of the files. I am not using or calling this language file in any file still and I am getting this error.

function insert(){
    $this->load->library('form_validation');

    $this->form_validation->set_rules('username_field', 'username', 'required');
    $this->form_validation->set_rules('firstname_field', 'firstname', 'required');
    $this->form_validation->set_rules('lastname_field', 'lastname', 'required');
    $this->form_validation->set_rules('email_field', 'email', 'required|valid_email|callback_isEmailExist');

    if ($this->form_validation->run() == FALSE) {

        $this->create();

    }
}

function isEmailExist($email) {
    $this->load->library('form_validation');
    $is_exist = $this->users->isEmailExist($email);

    if ($is_exist) {
        $this->form_validation->set_message(
            'isEmailExist', 'Email address is already exist.'
        );    
        return false;
    } else {
        return true;
    }
}

What is the solution for this?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

CI form_validation library uses language file for display error message.You are using required valid_email those error message is written inside form_validation_lang.php.

form_validation library loads the language file(form_validation_lang.php) itself whether you load or not.You can open the library file and look at the run function you will see a line $this->CI->lang->load('form_validation');

This file located either inside your system/language/your_language/ or application/language/your_language/.

That error message says you missed the file inside any of the folder.If you download the original CI files it should be inside system/language/english/ folder.If you don’t see the file download CI and restore the file there.

Solution 2

there are two locations whith language files
1. in the system/language folder
2. in the application/language folder

For formvalidation CI uses the system/language folder

in your config.php (in the application/config) you specify wich language folder you want to use.

So, open your config file and look for

$config['language'] = 'en';

look into your system/language folder and look if there is a folder named “en” and if there is a form_validation_lang.php file in it.

if not, I think there is a folder named english.
then the solutions would be to change the 'en' in your config to english.

Solution 3

Go to application/config/config.php you should have $config['language'] = 'en';.
Change it to $config['language'] = 'english';.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply