I would not create 4 columns informing which language it would be like in the example you cited:
titulo_br | titulo_en | conteudo_br | conteudo_en
I would make a normal table and only create a column to know in which language that record is
id | titulo | conteudo | idioma
An example registry in this table:
1 | Um título | Conteudo da tabela em português | pt
2 | One Title | Content of the table in english | en
If it's specific content to show, create a column
call for example ID and place a word, ID
or whatever you find easiest and in SELECT
make a WHERE
by pulling this
content.
Create the links to select the language of the site / content such as
<a href="<?php echo base_url('idioma/pt');?>">Português</a>
<a href="<?php echo base_url('idioma/en');?>">Inglês</a>
In application / config / routes.php add:
$route['idioma/(:any)'] = 'idioma/selecionar_idioma/$1';
Controller language
<?php
class Idioma extends CI_Controller{
public function selecionar_idioma($idioma){
$this->session->set_userdata('idioma', $idioma);
redirect('index'); //Página inicial ou outra página
}
}
?>
When you display the contents of the table for example:
$idioma = $this->session->userdata('idioma');
$this->db->where('idioma', $idioma);
$query = $this->db->get('tabela_do_conteudo');
foreach($query->result() as $result){
echo $result->titulo.'<br />';
echo $result->conteudo.'<br /><br />';
}
I would do more or less like this. You can also use cookies
if you think it's better than session
.