다국어지원 소스 수정 스터디
- 강임
- 0
- 1,767
- 글주소
- 10-29
안녕하세요?
다국어 지원을 준비하고 있습니다. 함께 업데이트하며 진행하면 어떨까 하여 글 올립니다.
1. application => language => english/korean 작성
2. application/core에 CB_Langphp
3. routes에 update
4. view layout update
<?php echo lang('text'); ?>
http://www.ciboard.co.kr/user_guide/kr/libraries/language.html
CB_Lang.php
<?php
(defined('BASEPATH')) OR exit('No direct script access allowed');
/**
* @property CI_Config $config
* @property CI_Session $session
*/
class CB_Lang extends CB_Lang {
/***
* pages of site in menu
*/
function __construct() {
parent::__construct();
$this->load_lang();
}
/**
* return module language file
*/
protected function load_lang() {
if ($this->uri->segment(1) == 'kr' ||
$this->uri->segment(1) == 'en'||
$this->uri->segment(1) == 'cn'
) {
$this->session->set_userdata("lang", $this->uri->segment(1));
redirect($this->session->flashdata('redirectToCurrent'));
}
if ($this->session->userdata('lang') == "cn") {
$lang = "chienes";
$this->config->set_item('language',$lang);
$this->session->set_userdata("lang",'cn');
} elseif ($this->session->userdata('lang') == "en") {
$lang = "english";
$this->config->set_item('language',$lang);
$this->session->set_userdata("lang",'en');
}else {
$lang = "korean";
$this->config->set_item('language',$lang);
$this->session->set_userdata("lang",'kr');
}
$this->lang->load($moduleName, $lang);
}
/**
* present master page includes header and footer
* @param string $main_containt
* @param array $data
*/
function view($main_containt, $data = null) {
$this->load->view('_layout/bootstrap/layout');
$this->load->view($main_containt, $data);
}
}