0

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.

1
  • It might be worth just doing a simple empty($_POST['language']) check on that value and setting a default value for if 1 as not been set. You could do something like $language = (! empty($_POST['language'])) ? $_POST['language'] : 'default-language';` to make it easier to read Commented Mar 3, 2014 at 11:19

2 Answers 2

4

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);
}
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.