getDefaultLocale() 공개 메소드

public getDefaultLocale ( ) : string
리턴 string
예제 #1
0
 public function sortCollectionByLocales(Nextras\Orm\Mapper\Dbal\DbalCollection $collection, string $column) : Nextras\Orm\Mapper\Dbal\DbalCollection
 {
     $builder = $collection->getQueryBuilder();
     foreach ([$this->translator->getLocale(), $this->translator->getDefaultLocale()] as $locale) {
         $separator = strpos($locale, '_');
         $subLocales = $separator === FALSE ? [$locale] : [$locale, substr($locale, 0, $separator)];
         foreach ($subLocales as $subLocale) {
             $builder->addOrderBy(implode('=', [$column, '%s']) . ' DESC', $subLocale);
         }
     }
     return $collection;
 }
 /**
  * Saves translation to given catalog
  */
 public function handleSaveTranslation()
 {
     $locale = $this->getParameter('language', $this->translator->getDefaultLocale());
     $code = $this->getParameter('code');
     if (!$code) {
         $this->presenter->sendJson(array('error' => 'Missing "code" parameter'));
     }
     try {
         $this->saveTranslationToCatalogue($locale, $code, $this->presenter->getParameter('string'));
     } catch (Kdyby\TranslationControl\UnsupportedCatalogException $e) {
         $this->presenter->sendJson(array('error' => 'Only Neon format as catalog is supported at this moment.'));
     }
     $this->presenter->sendJson(array('status' => 1));
 }
예제 #3
0
 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'));
     }
 }
예제 #4
0
 public function startup()
 {
     parent::startup();
     $this->actualLanguage = Language::findOneBy(array('locale' => $this->translator->getLocale(), 'public' => true)) ?: Language::findOneBy(array('locale' => $this->translator->getDefaultLocale()));
     $this->translatorSession->setLocale($this->actualLanguage->getLocale());
 }
예제 #5
0
 protected function startup()
 {
     parent::startup();
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->template->page = $this->database->table("pages")->get($this->getParameter("page_id"));
     $this->template->settings = $this->database->table("settings")->fetchPairs("setkey", "setvalue");
     /* Maintenance mode */
     if ($this->template->settings["maintenance_enabled"]) {
         if (empty($this->template->settings["maintenance_message"])) {
             include_once '.maintenance.php';
         } else {
             echo $this->template->settings["maintenance_message"];
         }
         exit;
     }
     /* IP mode */
     $ip = explode(";", $this->template->settings["site_ip_whitelist"]);
     if (strlen($this->template->settings["site_ip_whitelist"]) < 4 || in_array($_SERVER['REMOTE_ADDR'], $ip)) {
     } else {
         if (empty($this->template->settings["maintenance_message"])) {
             include_once '.maintenance.php';
         } else {
             echo $this->template->settings["maintenance_message"];
         }
         exit;
     }
     /* Secret password mode */
     $secret = $_COOKIE["secretx"];
     if ($this->template->settings['site_cookie_whitelist'] != '') {
         if ($this->template->settings["site_cookie_whitelist"] != $secret) {
             if ($_GET["secretx"] == $this->template->settings["site_cookie_whitelist"]) {
                 setcookie("secretx", $this->template->settings["site_cookie_whitelist"], time() + 3600000);
             } else {
                 if (empty($this->template->settings["maintenance_message"])) {
                     include_once '.maintenance.php';
                 } else {
                     echo $this->template->settings["maintenance_message"];
                 }
                 exit;
             }
         } else {
             $message = "5";
         }
     }
     // Arguments for language switch box
     $parametres = $this->getParameters(TRUE);
     unset($parametres["locale"]);
     $this->template->args = $parametres;
     $this->template->langSelected = $this->translator->getLocale();
     $this->template->langDefault = $this->translator->getDefaultLocale();
     if ($this->translator->getLocale() != $this->translator->getDefaultLocale()) {
         $this->template->langSuffix = '_' . $this->translator->getLocale();
     }
     try {
         if ($this->user->isLoggedIn()) {
             $this->template->isLoggedIn = TRUE;
             $this->template->member = $this->database->table("users")->get($this->user->getId());
         } else {
             $this->template->isLoggedIn = FALSE;
         }
     } catch (\Exception $e) {
         $this->template->isLoggedIn = FALSE;
     }
     $this->template->appDir = APP_DIR;
     $this->template->languageSelected = $this->translator->getLocale();
     if ($this->template->settings['store:enabled']) {
         $cart = new Model\Store\Cart($this->database, $this->user->getId(), $this->template->isLoggedIn);
         $cart->cleanCarts();
         $this->template->cartObject = $cart;
         $this->template->cartId = $cart->getCartId();
         $this->template->cartItems = $cart->getCartItems();
         $this->template->cartItemsArr = $cart->getItems();
         $this->template->cartTotal = $cart->getCartTotal($this->template->settings);
         $this->template->cartInfo = $cart->getCart();
         if ($cart->getItems()) {
             $this->template->cart = $cart->getItems()->order("id");
         }
         $bonus = new Model\Store\Bonus($this->database);
         $bonus->setUser($this->user->getId());
         $bonus->setCartTotal($this->template->cartTotal);
         $amountBonus = $bonus->getAmount($cart->getCartTotal($this->template->settings));
         $this->template->amountBonus = abs($amountBonus);
         if ($amountBonus <= 0) {
             $this->template->bonusEnabled = true;
         } else {
             $this->template->bonusEnabled = false;
         }
     }
 }
예제 #6
0
파일: Locale.php 프로젝트: Achse/petrhejna
 /**
  * @return string
  */
 public function getLocale() : string
 {
     $locale = $this->translator->getLocale();
     return $locale ?: $this->translator->getDefaultLocale();
 }