I've read absolutely every SO post regarding internationalization in CakePHP and nothing seems to be working for me. I'm using CakePHP 2.5.1.
In config/bootstrap.php:
//Default language
Configure::write('Config.language', 'spa');
In controller/AppController.php:
public $components = array('Session', 'DebugKit.Toolbar');
public function beforeFilter()
{
//Set the UI lang preference
if($this->Session->check('Config.language'))
{
Configure::write('Config.language', $this->Session->read('Config.language'));
}
}
My file structure is as so:
/Locale/
- default.mo
- default.po
- default.pot
- eng/LC_MESSAGES/
- default.mo
- default.po
I have links on the view as such:
echo '<p class="">' . $this->Html->link('EN', array('controller' => 'users', 'action' => 'lang', 'en')) . '</p>';
echo '<p class="">' . $this->Html->link('ES', array('controller' => 'users', 'action' => 'lang', 'es')) . '</p>';
and my Users controller does the following with this:
public function lang($which)
{
if($which == "en")
{
$this->Session->write('Config.language', 'eng');
} elseif($which == "es")
{
$this->Session->write('Config.language', 'spa');
} else
{
$this->Session->setFlash(_('Unknown language.'), 'flash_red');
}
$this->redirect('/');
}
When I click on any of the links (EN or ES), the page reloads but shows the normal text.
Any clue on what I could be missing? Or any tips on where to start debugging in the Cake core code?
PD. The error logs don't show anything.
Thanks!