Dear All I would like to share to all of you about how to create multiple languages using codeigniter.
Please read description below and download by click here
1. Create your lanaguage file in folder language:
In each file write text you want to translate
->application->config->autoioad.php
$autoload['language'] = array('english'); // we use for set deduault language
$autoload['helper'] = array('url','language','lang_helper'); // load url, language and lang_helper
3. create file in view.php
' : '' ?>
4.Create function languages() in controller Welcome.php1. Create your lanaguage file in folder language:
- languag
-
- khmer
- khmer_lang.php
- english
- english_lang.php
- Chinese
- chinese_lang.php
//example: english_lang.php $lang['hellow'] = 'Hello world'; ............................................................. //khmer_lang.php: $lang['hellow'] = 'សួស្តី'; //chinese_lang.php : $lang['hellow'] = '你好';
->application->config->autoioad.php
$autoload['language'] = array('english'); // we use for set deduault language
$autoload['helper'] = array('url','language','lang_helper'); // load url, language and lang_helper
3. create file in view.php
session->userdata("lang") == null ? "english" : $this->session->userdata("lang"); $this->lang->load($lang, $lang); ?>Welcome CI multi language | Youlay
session->userdata("lang") == null ? "english" : $this->session->userdata("lang"); $this->lang->load($lang, $lang); } public function index() { $this->load->view('welcome_message'); } public function languages($get_lang){ $this->session->set_userdata('lang',$get_lang); redirect(base_url()); } }5.Create helper file in folder helper(lang_helper.php)
lang->line($label); if($rs){ return $rs; } else { return $label; } } ?>
-------------------------------------------------------------------------------------------
thank run your project:
Note if it not work, you can download file work. or you can comment for question. Thanks
0 comments:
Post a Comment