[eluser]Ener1[/eluser]
Hi,
Im currently using something like this
in the constructor of your controllers
Code:
if(!isset($this->session->userdata['lng'])||$this->session->userdata['lng']=='')
{
$this->session->userdata['lng']='es';
}
Then I have a method called CL(change language)
Code:
function cl($lan,$actual)
{
$actua = str_replace('-','/',$actual);
$this->lng=$lan;
$this->session->set_userdata(array('lng'=>$this->lng));
redirect(base_url().$actua, 'refresh');
}
And from the views
Code:
<a href="<?php echo base_url(); ?>home/cl/es/<?php echo $actual;?>">lang->line('es')?>" class="idioma">
<img src="<?php echo base_url();?>images/img_sitio/es.jpg" alt="Español" /> Español
</a>
<a href="<?php echo base_url(); ?>home/cl/en/<?php echo $actual;?>">lang->line('en')?>" class="idioma">
<img src="<?php echo base_url();?>images/img_sitio/en.jpg" alt="English" /> English
</a>
Plus you can just put your static text in the language arrays ( for this just follow the CI user guide ), and in that array the actual language. So you have it everywhere. Example:
Code:
<?php
//idiomas estilo destacado
$lang['en'] = "text-decoration:underline;";
$lang['es'] = "text-decoration:none;";
$lang['frase'] = "Quote";
$lang['idioma'] = "Language";
$lang['bienvenida'] = "Welcome";
$lang['noticias'] = "News";
and in my Database I also have an language field, so I can put dynamic data in multiple langages too.
I hope this helps