當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Admin::getLanguageFile方法代碼示例

本文整理匯總了PHP中Pimcore\Tool\Admin::getLanguageFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Admin::getLanguageFile方法的具體用法?PHP Admin::getLanguageFile怎麽用?PHP Admin::getLanguageFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimcore\Tool\Admin的用法示例。


在下文中一共展示了Admin::getLanguageFile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: jsonTranslationsSystemAction

 public function jsonTranslationsSystemAction()
 {
     $this->getResponse()->setHeader("Content-Type", "text/javascript", true);
     $language = $this->getParam("language");
     $languageFile = Tool\Admin::getLanguageFile($language);
     if (!is_file($languageFile)) {
         $languageFile = Tool\Admin::getLanguageFile("en");
     }
     $row = 1;
     $handle = fopen($languageFile, "r");
     while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
         $translations[$data[0]] = $data[1];
     }
     fclose($handle);
     $broker = \Pimcore\API\Plugin\Broker::getInstance();
     $pluginTranslations = $broker->getTranslations($language);
     //$pluginTranslations = $this->getApiPluginBroker()->getTranslations($language);
     $translations = array_merge($pluginTranslations, $translations);
     $this->view->translations = $translations;
 }
開發者ID:pawansgi92,項目名稱:pimcore2,代碼行數:20,代碼來源:MiscController.php

示例2: jsonTranslationsSystemAction

 public function jsonTranslationsSystemAction()
 {
     $this->getResponse()->setHeader("Content-Type", "text/javascript", true);
     $language = $this->getParam("language");
     $languageFiles = [$language => Tool\Admin::getLanguageFile($language), "en" => Tool\Admin::getLanguageFile("en")];
     $translations = [];
     foreach ($languageFiles as $langKey => $languageFile) {
         if (file_exists($languageFile)) {
             $rawTranslations = json_decode(file_get_contents($languageFile), true);
             foreach ($rawTranslations as $entry) {
                 if (!isset($translations[$entry["term"]])) {
                     $translations[$entry["term"]] = $entry["definition"];
                 }
             }
         }
     }
     $broker = \Pimcore\API\Plugin\Broker::getInstance();
     $pluginTranslations = $broker->getTranslations($language);
     $translations = array_merge($pluginTranslations, $translations);
     $this->view->translations = $translations;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:21,代碼來源:MiscController.php

示例3: 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

示例4: 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


注:本文中的Pimcore\Tool\Admin::getLanguageFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。