I have to change the locale dynamically depending which language the user wants.
I can set the locale in the Application/Module.php like this :
public function onBootstrap(MvcEvent $e)
{
$translator = $e->getApplication()->getServiceManager()->get('translator');
$translator->setLocale('hu_HU');
}
But, how can I do this in the controller, if I want to change languages ? I tried this, but after this I can change the locale only for this one request and not global.
$translator = $this->getServiceLocator()->get('translator');
$translator->setLocale('srb_SRB');
Set up the default locale at configuration level! See #61 of module.config.php
from ZendSkeletonApplications Application Module
'translator' => array(
'locale' => 'en_US',
)