Unable to load the requested language file: langua

2020-02-06 05:34发布

问题:

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?

回答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.



回答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.



回答3:

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