Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created April 13, 2012 14:38
Show Gist options
  • Save mpmont/2377323 to your computer and use it in GitHub Desktop.
Save mpmont/2377323 to your computer and use it in GitHub Desktop.
Linguagem
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Config extends CI_Config {
function site_url($uri = '')
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
if (function_exists('get_instance'))
{
$CI =& get_instance();
//$uri = $CI->lang->localized($uri);
}
return parent::site_url($uri);
}
}
//No construtor do my controller
public function __construct()
{
parent::__construct();
$this->data['language'] = $this->uri->segment(1);
//If not defined redirect
if(empty($this->data['language']))
redirect('pt/home');
//else get the correct lang pack
switch ($this->data['language']) {
case 'pt':
$this->lang->load('front-end', 'portuguese');
break;
case 'en':
$this->lang->load('front-end', 'english');
break;
default:
$this->lang->load('front-end', 'english');
break;
}
//Load Dependencies
$this->load->model('article_model', 'article');
}
$route['^pt/(.+)$'] = "$1";
$route['^en/(.+)$'] = "$1";
$route['default_controller'] = "home";
$route['^pt$'] = $route['default_controller'];
$route['^en$'] = $route['default_controller'];
$route['404_override'] = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment