title: How to change the site language in codeigniter
body: <p>I have developed website in codeigniter and now i want it to be multi-language.</p>
  
  <p>I have followed a tutorial working with hooks. Here is my hook.php</p>
  
  <pre><code>$hook['post_controller_constructor']=array(
                                     'class'=&gt;'LanguageLoader',
                                     'function'=&gt;'initialize',
                                     'filename'=&gt;'LanguageLoader.php',
                                     'filepath'=&gt;'hooks'
                                     );
  </code></pre>
  
  <p>and I have created a class and placed it inside the hooks folder.</p>
  
  <pre><code>class LangSwitch extends CI_Controller
  {
      public function __construct()
      {
          parent::construct();
          $this-&gt;load-&gt;helper('url');
      }
  
     function switchLanguage($language="")
     {
         $language=($language!="") ? $language:"english"; 
         $this-&gt;session-&gt;set_userdata('site_lang',$language);
         redirect(base_url());
     }
  }
  </code></pre>
  
  <p>and here is another file which is also placed inside the hooks folder</p>
  
  <pre><code>class LanguageLoader
  {
      function initialize()
      {
          $CI=&amp;get_instance();
          $CI-&gt;load-&gt;helper('language');
          $site_lang=$CI-&gt;session-&gt;userdata('site_lang');
          if($site_lang)
          {
              $CI-&gt;lang-&gt;load('dari','dari');
          }
          else
          {
              $CI-&gt;lang-&gt;load('english','english');
          }
      }
  }
  </code></pre>
  
  <p>and here is my view file.</p>
  
  <pre><code>&lt;a href='&lt;?=site_url('LangSwitcher/switchLanguage/english')?&gt;'&gt;English&lt;/a&gt;
  </code></pre>
  
  <p>and it says that "The requested page was not found ". Can any body find it what is happening ?</p>