无法加载请求的语言文件: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
Unable to load the requested language file: language/en/form_validation_lang.php
提问by
I am using codeigniter 2.1.4
我正在使用 codeigniter 2.1.4
In that I am using form_validation
library 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_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
.
CIform_validation
库使用语言文件来显示错误信息。你正在使用required
valid_email
那些写在里面的错误信息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');
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/language
folder
2. in the application/language
folder
语言文件有两个位置 1. 在system/language
文件夹中 2. 在application/language
文件夹中
For formvalidation CI uses the system/language
folder
对于表单验证 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/language
folder and look if there is a folder named "en" and if there is a form_validation_lang.php
file 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.php
you should have $config['language'] = 'en';
.
Change it to $config['language'] = 'english';
.
去application/config/config.php
你应该有$config['language'] = 'en';
。将其更改为$config['language'] = 'english';
.