0

I try to make multi language site in codeigniter, but i have a problem....

I want two lang (englush, german). and switch without url.... in admin panel settings i have:

<div class="form-group">
    <label for="language">Language</label>
    <select name="language" class="form-control">
       <option value="english">English</option>
       <option value="german" selected="selected">Deutsch</option>
   </select>
</div>

In db have settings table and write only selected lang. settings table: id 1| language german

I have a model who get value

    function getLang(){
    $this->db->select('language');
    $this->db->where('id',1);
    $data=$this->db->get('settings')->result_array();
    return $data[0];
}

And Core-> My_Controller:

 $this->load->model('Setting');
    $this->lang->load('admin', $this->Setting->getLang()); //admin_lang.php is located in language folder in english and german folders

When i change the value in database language do not change... load only default language from config.php $config['language'] = 'english';

Where is the problem?

1 Answer 1

1

Hope this will help you :

Your model's method getLang should be like this, do this to return language

function getLang()
{
    $this->db->select('language');
    $this->db->where('id',1);
    $query =$this->db->get('settings');
    if ($query->num_rows() > 0)
    {
        return $query->row()->language;
    }
}
Sign up to request clarification or add additional context in comments.

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.