[eluser]Unknown[/eluser]
hi,
i am have create a Librarie for CI witch allows you to create a multi-language page:
Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class multi_language
{
private $language;
private $object;
public function __construct()
{
$this->object =& get_instance();
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$lange = explode(';', $lang);
$lange2 = explode('-', $lange[0]);
$lang = $lange2[0];
$dir_name = './system/application/views/' . $lang . '/';
if(is_dir($dir_name))
{
$this->language = $lang;
}else{
$this->language = 'en';
}
}
public function load_view($name,$data = array())
{
$this->object->load->view($this->language . '/' . $name, $data);
}
}
?>
Create the Dir's and the Views like this:
Code:
system\application\views\de\welcome.php
system\application\views\fr\welcome.php
system\application\views\en\welcome.php
save the librarie in
Code:
system\application\libraries\multi_language.php
and implement it in you controller like this:
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->load->library('multi_language');
}
function index()
{
$this->multi_language->load_view('welcome');
}
}
?>
I hope you can use it.
And sry about my bad english... xD
good luck