当前位置: 首页>>代码示例>>PHP>>正文


PHP Admin::getLanguages方法代码示例

本文整理汇总了PHP中Pimcore\Tool\Admin::getLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::getLanguages方法的具体用法?PHP Admin::getLanguages怎么用?PHP Admin::getLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Tool\Admin的用法示例。


在下文中一共展示了Admin::getLanguages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getByKeyLocalized

 /**
  * @param $id
  * @param bool $create
  * @param bool $returnIdIfEmpty
  * @param null $language
  * @return array
  * @throws \Exception
  * @throws \Zend_Exception
  */
 public static function getByKeyLocalized($id, $create = false, $returnIdIfEmpty = false, $language = null)
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         $language = $user->getLanguage();
     } elseif ($user = Tool\Authentication::authenticateSession()) {
         $language = $user->getLanguage();
     } elseif (\Zend_Registry::isRegistered("Zend_Locale")) {
         $language = (string) \Zend_Registry::get("Zend_Locale");
     }
     if (!in_array($language, Tool\Admin::getLanguages())) {
         $config = \Pimcore\Config::getSystemConfig();
         $language = $config->general->language;
     }
     return self::getByKey($id, $create, $returnIdIfEmpty)->getTranslation($language);
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:24,代码来源:Admin.php

示例2: initTranslations

 /**
  * @param $instance
  * @throws \Zend_Exception
  */
 public static function initTranslations($instance)
 {
     $language = "en";
     $locale = $instance->getLanguage();
     if ($locale) {
         $locale = new \Zend_Locale($locale);
         foreach ([(string) $locale, $locale->getLanguage()] as $localeVariant) {
             if (in_array($localeVariant, AdminTool::getLanguages())) {
                 $language = $localeVariant;
                 break;
             }
         }
     }
     //add translations to registry
     $coreLanguageFile = AdminTool::getLanguageFile($language);
     $translator = new \Zend_Translate('Pimcore\\Translate\\Adapter\\Json', $coreLanguageFile, $language);
     $languageFile = AdminTool::getLanguageFile($language);
     $translator->addTranslation($languageFile, $language);
     if (\Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = \Zend_Registry::get("Zend_Locale");
         @$translator->setLocale($locale);
     }
     \Zend_Registry::set("Zend_Translate", $translator);
     if ($instance) {
         $instance->setTranslator($translator);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:31,代码来源:Admin.php

示例3: initTranslations

 /**
  * @param $instance
  * @throws \Zend_Exception
  */
 public static function initTranslations($instance)
 {
     //add translations to registry
     $coreLanguageFile = AdminTool::getLanguageFile("en");
     $translator = new \Zend_Translate('Pimcore\\Translate\\Adapter\\Json', $coreLanguageFile, 'en');
     $availableLanguages = AdminTool::getLanguages();
     foreach ($availableLanguages as $lang) {
         if ($lang != "en") {
             $languageFile = AdminTool::getLanguageFile($lang);
             $translator->addTranslation($languageFile, $lang);
         }
     }
     if (\Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = \Zend_Registry::get("Zend_Locale");
         @$translator->setLocale($locale);
     }
     \Zend_Registry::set("Zend_Translate", $translator);
     if ($instance) {
         $instance->setTranslator($translator);
     }
 }
开发者ID:sfie,项目名称:pimcore,代码行数:25,代码来源:Admin.php

示例4: getByKey

 /**
  * @param $id
  * @param bool $create
  * @param bool $returnIdIfEmpty
  * @return static
  * @throws \Exception
  * @throws \Zend_Exception
  */
 public static function getByKey($id, $create = false, $returnIdIfEmpty = false)
 {
     $cacheKey = "translation_" . $id;
     if (\Zend_Registry::isRegistered($cacheKey)) {
         return \Zend_Registry::get($cacheKey);
     }
     $translation = new static();
     $idOriginal = $id;
     $id = mb_strtolower($id);
     if ($translation instanceof Model\Translation\Admin) {
         $languages = Tool\Admin::getLanguages();
     } else {
         $languages = Tool::getValidLanguages();
     }
     try {
         $translation->getDao()->getByKey(self::getValidTranslationKey($id));
     } catch (\Exception $e) {
         if (!$create) {
             throw new \Exception($e->getMessage());
         } else {
             $translation->setKey($id);
             $translation->setCreationDate(time());
             $translation->setModificationDate(time());
             $translations = [];
             foreach ($languages as $lang) {
                 $translations[$lang] = "";
             }
             $translation->setTranslations($translations);
             $translation->save();
         }
     }
     if ($returnIdIfEmpty) {
         $translations = $translation->getTranslations();
         foreach ($languages as $language) {
             if (!array_key_exists($language, $translations) || empty($translations[$language])) {
                 $translations[$language] = $idOriginal;
             }
         }
         $translation->setTranslations($translations);
     }
     // add to key cache
     \Zend_Registry::set($cacheKey, $translation);
     return $translation;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:52,代码来源:AbstractTranslation.php

示例5: getAvailableAdminLanguagesAction

 public function getAvailableAdminLanguagesAction()
 {
     $langs = array();
     $availableLanguages = Tool\Admin::getLanguages();
     $locales = Tool::getSupportedLocales();
     foreach ($availableLanguages as $lang) {
         if (array_key_exists($lang, $locales)) {
             $langs[] = array("language" => $lang, "display" => $locales[$lang]);
         }
     }
     $this->_helper->json($langs);
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:12,代码来源:SettingsController.php

示例6: addAdminTranslationKeysAction

 public function addAdminTranslationKeysAction()
 {
     $this->removeViewRenderer();
     $keys = $this->getParam("keys");
     if ($keys) {
         $availableLanguages = Tool\Admin::getLanguages();
         $data = \Zend_Json_Decoder::decode($keys);
         foreach ($data as $translationData) {
             $t = null;
             // reset
             try {
                 $t = Translation\Admin::getByKey($translationData);
             } catch (\Exception $e) {
                 \Logger::log($e);
             }
             if (!$t instanceof Translation\Admin) {
                 $t = new Translation\Admin();
                 $t->setKey($translationData);
                 $t->setCreationDate(time());
                 $t->setModificationDate(time());
                 foreach ($availableLanguages as $lang) {
                     $t->addTranslation($lang, "");
                 }
                 try {
                     $t->save();
                 } catch (\Exception $e) {
                     \Logger::log($e);
                 }
             }
         }
     }
 }
开发者ID:quorak,项目名称:pimcore,代码行数:32,代码来源:TranslationController.php

示例7: installAdminTranslations

 public function installAdminTranslations()
 {
     $csv = PIMCORE_PLUGINS_PATH . '/Toolbox/install/translations/data.csv';
     Admin::importTranslationsFromFile($csv, true, \Pimcore\Tool\Admin::getLanguages());
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:5,代码来源:Install.php


注:本文中的Pimcore\Tool\Admin::getLanguages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。