[eluser]jegbagus[/eluser]
actually CI already provide multi language support...
this is my code (placed in extend controller), just change the cookies with your language name.
Code:
/*
* lang retriever
* load appropriate lang for site
*/
private function load_lang(){
// get lang from cookies
$lang = get_cookie('lang');
// default language is english if lang not set or lang was invalid
if($lang == null || $lang == '' || !in_array($lang,$this->available_lang)) {
$lang = 'english';
// set cookies
$cookie = array(
'name' => 'lang',
'value' => $lang,
'expire' => '216000',
);
set_cookie($cookie);
}
// load appropriate lang file
$this->data['lang'] = $lang;
$this->lang->load('site',$lang);
}
in your application folder, it will be :
Code:
application
|
| language
| english
| site_lang.php
| your lang
| site_lang.php
site_lang example
Code:
<?php if(!defined('BASEPATH')) exit("Hack Attempt?");
$lang['home'] = 'Home';
$lang['aboutus'] = 'About Us';
$lang['faq'] = 'FAQ';
$lang['contactus'] = 'Contact Us';
$lang['news'] = 'News';
$lang['pollresult'] = 'Poll Result';
$lang['profile'] = 'Profile';