getDefaultLanguage() публичный статический Метод

public static getDefaultLanguage ( ) : null | string
Результат null | string
Пример #1
0
 /**
  * @throws \Exception
  * @param null $language
  * @return string
  */
 public function getLanguage($language = null)
 {
     if ($language) {
         return (string) $language;
     }
     // try to get the language from the registry
     try {
         $locale = \Zend_Registry::get("Zend_Locale");
         if (Tool::isValidLanguage((string) $locale)) {
             return (string) $locale;
         }
         throw new \Exception("Not supported language");
     } catch (\Exception $e) {
         return Tool::getDefaultLanguage();
     }
 }
Пример #2
0
 /**
  * @return string
  * @throws \Exception
  * @throws \Zend_Exception
  */
 protected function getTableName()
 {
     if (empty($this->tableName)) {
         // default
         $this->tableName = "object_" . $this->model->getClassId();
         if (!$this->model->getIgnoreLocalizedFields()) {
             $language = null;
             // check for a localized field and if they should be used for this list
             if (property_exists("\\Pimcore\\Model\\Object\\" . ucfirst($this->model->getClassName()), "localizedfields")) {
                 if ($this->model->getLocale()) {
                     if (Tool::isValidLanguage((string) $this->model->getLocale())) {
                         $language = (string) $this->model->getLocale();
                     }
                 }
                 if (!$language && \Zend_Registry::isRegistered("Zend_Locale")) {
                     $locale = \Zend_Registry::get("Zend_Locale");
                     if (Tool::isValidLanguage((string) $locale)) {
                         $language = (string) $locale;
                     }
                 }
                 if (!$language) {
                     $language = Tool::getDefaultLanguage();
                 }
                 if (!$language) {
                     throw new \Exception("No valid language/locale set. Use \$list->setLocale() to add a language to the listing, or register a global locale");
                 }
                 $this->tableName = "object_localized_" . $this->model->getClassId() . "_" . $language;
             }
         }
     }
     return $this->tableName;
 }
Пример #3
0
 /**
  * Detect and return user language.
  *
  * @return string|null
  */
 protected function detectLanguage()
 {
     // check force switch
     $lang = $this->getForcedLanguage();
     if (!$lang) {
         $lang = $this->getPreferredLanguage();
     }
     if (!$lang) {
         // check user browser
         $lang = $this->getBrowserLanguage();
     }
     if (!$lang) {
         // use default
         $lang = Tool::getDefaultLanguage();
     }
     $this->setPreferredLanguage($lang);
     return $lang;
 }