无法加载请求的语言文件:language/en/form_validation_lang.php

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29896938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:38:45  来源:igfitidea点击:

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

phpcodeigniter

提问by

I am using codeigniter 2.1.4

我正在使用 codeigniter 2.1.4

In that I am using form_validationlibrary for form validation.

因为我正在使用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

无法加载请求的语言文件: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?

解决这个问题的方法是什么?

采纳答案by Shaiful Islam

CI form_validationlibrary uses language file for display error message.You are using requiredvalid_emailthose error message is written inside form_validation_lang.php.

CIform_validation库使用语言文件来显示错误信息。你正在使用requiredvalid_email那些写在里面的错误信息form_validation_lang.php

form_validationlibrary 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');

form_validation库加载语言文件(form_validation_lang.php)本身,无论你加载与否。你可以打开库文件并查看运行函数你会看到一行$this->CI->lang->load('form_validation');

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

此文件位于您的system/language/your_language/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 downloadCI and restore the file there.

该错误消息表示您错过了任何文件夹内的文件。如果您下载原始 CI 文件,它应该在system/language/english/文件夹内。如果您没有看到文件,请下载CI 并在那里恢复文件。

回答by mdgeus

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

语言文件有两个位置 1. 在system/language文件夹中 2. 在application/language文件夹中

For formvalidation CI uses the system/languagefolder

对于表单验证 CI 使用system/language文件夹

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

在您的 config.php (在application/config)中,您指定要使用的语言文件夹。

So, open your config file and look for

因此,打开您的配置文件并查找

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

look into your system/languagefolder and look if there is a folder named "en" and if there is a form_validation_lang.phpfile in it.

查看您的system/language文件夹,看看是否有名为“en”的文件夹以及其中是否有form_validation_lang.php文件。

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

如果没有,我认为有一个名为english. 那么解决方案是将'en'配置中的更改为english.

回答by Nan

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

application/config/config.php你应该有$config['language'] = 'en';。将其更改为$config['language'] = 'english';.