문제

I have implement the Multiple Language using the Language Helper.I am loading the helper on drop-down change, means when user select any language then I load library according then. My problem is that if no language file found then it shows error

Unable to load the requested language file: language/abc/abc_lang.php

I want that if no file found then Simple English select. So I try this code but getting same error

$language = $_POST['language'];

if(($this->lang->load($language,$language)) == 1){
     $this->lang->load($language,$language);
}

else{
    $this->lang->load('english','english');
}

Anyone can tell me how to solve it.

도움이 되었습니까?

해결책

Error message is triggered by your attempt to load a non-existing language file in your conditional statement. I would recommend you checking if the language file exists before trying to load it:

if (file_exists(APPPATH."language/".$expectedLanguage."/".$expectedFile)) {
    $this->lang->load($expectedFile, $expectedLanguage);
}

다른 팁

You have to ensure that, how many option you have in drop-down that number of lang file you have to create on languages folder. then it will get its expected lang file as per you change from drop-down and not show error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top