Question

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.

Was it helpful?

Solution

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);
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top