Hi All! I have a problem with setting up Phalcon Incubator Gettext Adapter in a service container.
I want to set locale
from session. I have sth like this:
<?php
$di = new Phalcon\DI\FactoryDefault();
$di->setShared('session', function () {
$session = new Phalcon\Session\Adapter\Files();
$session->start();
return $session;
});
$di->set('t', function () {
//here is my problem
if(isset($_SESSION["locale"])){
$locale = $_SESSION["locale"];
}
else {
$locale = 'cz_CZ';
}
$t = new Phalcon\Translate\Adapter\Gettext(array(
'locale' => $locale,
'file' => 'messages',
'directory' => '../app/locale'
));
return $t;
},true);
but it doesn't work. I think the problem is that at the moment when I implement Gettext there is no session started yet. But I don't know how to solve it.
Thanks!