public function startup() { parent::startup(); if (!$this->user->loggedIn) { $this->redirect("Sign:in", ["backlink" => $this->storeRequest()]); } $this->translator->setLocale("en"); if ($this->getParameter("no_layout", false)) { $this->setLayout(false); } }
/** * @param Application $sender * @param Request $request */ public function onRequest(Application $sender, Request $request) { $params = $request->getParameters(); if ($request->getMethod() === Request::FORWARD && empty($params['locale'])) { return; } $this->request = $request; if (!$this->translator) { return; } $this->translator->setLocale(NULL); $this->translator->getLocale(); // invoke resolver }
/** * @inheritDoc */ public function setLocale($locale) { if ($locale instanceof Locale\Entity) { $locale = $locale->id; } parent::setLocale($locale); }
protected function startup() { parent::startup(); // Login check if ($this->getName() != 'Admin:Sign') { $role = $this->user->getRoles(); $roleCheck = $this->database->table("users_roles")->get($role[0]); if ($roleCheck->admin_access == 0) { $this->flashMessage($this->translator->translate('messages.sign.invalidLogin'), "error"); $this->redirect(':Admin:Sign:in'); } if ($this->user->isLoggedIn()) { } else { if ($this->user->logoutReason === Nette\Security\IUserStorage::INACTIVITY) { $this->flashMessage($this->translator->translate('messages.sign.youWereLoggedIn'), "note"); } $this->redirect('Sign:in', array('backlink' => $this->storeRequest())); } } if ($this->user->isLoggedIn()) { $this->template->isLoggedIn = TRUE; $this->template->member = $this->database->table("users")->get($this->user->getId()); } // Set values from db $this->template->settings = $this->database->table("settings")->fetchPairs("setkey", "setvalue"); $this->template->appDir = APP_DIR; $this->template->signed = TRUE; $this->template->langSelected = $this->translator->getLocale(); // Set language from cookie if ($this->context->httpRequest->getCookie('language_admin') == '') { $this->translator->setLocale($this->translator->getDefaultLocale()); } else { $this->translator->setLocale($this->context->httpRequest->getCookie('language_admin')); } }
public function handleChangeLocale($locale) { $this->translator->setLocale($locale); $this->redirect('this'); }