当前位置: 首页>>代码示例>>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;未经允许,请勿转载。