/** * Change locale. * * @return void */ public function changeAction() { $redirect = $this->getRequest()->getHeader('Referer')->uri()->getPath(); $newLocale = (string) $this->params()->fromQuery('set'); $locales = Locales::getAvailableLocales(); if (array_key_exists($newLocale, $locales)) { if ($this->authService->hasIdentity()) { $user = $this->authService->getIdentity(); $this->userService->changeLocaleByUser($user, $newLocale); $user->setLanguage($newLocale); $this->authService->getStorage()->write($user); } $session = new Container('locale'); $session->locale = $newLocale; } return $this->redirect()->toUrl($redirect); }
public function getAvailableTranslatableLocales() { return Locales::getAvailableLocales(); }