Codeigniter:使用数据库和语言文件的多语言

I am converting a site to multilingual . In this process for automation of conversion i am using language files for like menu,static text etc . I was thinking of merging this methodology to also retrieve content from database based on language .

Like admin is entering multiple content for each language .I tried several things couldnt find way to manage this ...

Here is my code. ....

created a hook ...

$hook['post_controller_constructor'] = array(
    'class' => 'LanguageLoader',
    'function' => 'initialize',
    'filename' => 'LanguageLoader.php',
    'filepath' => 'hooks'
);

and in hooks.php

    class LanguageLoader
{
    function initialize() {
        $ci =& get_instance();
        $ci->load->helper('language');

        $site_lang = $ci->session->userdata('site_lang');

        if ($site_lang) {
            $ci->lang->load('topmenu',$ci->session->userdata('site_lang'));
        } else {
            $ci->lang->load('topmenu','english');
        }
    }
}

and then controller...

class Lang extends MX_Controller {
 public function __construct() {
        parent::__construct();
        $this->load->helper('url');
    }

    function change($language = "") {

        $language = ($language != "") ? $language : "english";
        $this->session->set_userdata('site_lang', $language);
        redirect(base_url());
    }

    function index() {        
        // get partials
      }

}

and simply calling like this ...

<?php echo lang('sign_up')?>

A bit late, but Language Class Extended DB is a very good solution.

use in constructor controller

class Service extends CI_Controller {

    public function __construct() { 

        parent::__construct();
        header('Content-Type: application/json; charset=utf-8');   
    }

    public function func1....
    {
        //code 
    }
}