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


PHP IOHelper::getFolders方法代码示例

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


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

示例1: loadMessages

 /**
  * Loads the message translation for the specified language and category.
  *
  * @param string $category The message category
  * @param string $language The target locale
  *
  * @return array The loaded messages
  */
 protected function loadMessages($category, $language)
 {
     if ($category !== 'craft') {
         $parentMessages = parent::loadMessages($category, $language);
         // See if there any craft/translations for Yii's system messages.
         if (($filePath = IOHelper::fileExists(craft()->path->getSiteTranslationsPath() . $language . '.php')) !== false) {
             $parentMessages = array_merge($parentMessages, include $filePath);
         }
         return $parentMessages;
     }
     if (!isset($this->_translations[$language])) {
         $this->_translations[$language] = array();
         // Plugin translations get added first so they always lose out for conflicts
         if (craft()->isInstalled() && !craft()->isInMaintenanceMode()) {
             // Don't use PluginService, but go straight to the file system. Who cares if they are disabled.
             $pluginPaths = IOHelper::getFolders(craft()->path->getPluginsPath());
             if ($pluginPaths) {
                 foreach ($pluginPaths as $pluginPath) {
                     $paths[] = $pluginPath . 'translations/';
                 }
             }
         }
         // Craft's translations are up next
         $paths[] = craft()->path->getCpTranslationsPath();
         // Add in Yii's i18n data, which we're going to do some special parsing on
         $paths[] = craft()->path->getFrameworkPath() . 'i18n/data/';
         // Site translations take the highest precidence, so they get added last
         $paths[] = craft()->path->getSiteTranslationsPath();
         // Look for translation file from least to most specific. For example, nl.php gets loaded before nl_nl.php.
         $translationFiles = array();
         $parts = explode('_', $language);
         $totalParts = count($parts);
         for ($i = 1; $i <= $totalParts; $i++) {
             $translationFiles[] = implode('_', array_slice($parts, 0, $i));
         }
         // Now loop through all of the paths and translation files and import the ones that exist
         foreach ($paths as $folderPath) {
             if (IOHelper::folderExists($folderPath)) {
                 foreach ($translationFiles as $file) {
                     $path = $folderPath . $file . '.php';
                     if (IOHelper::fileExists($path)) {
                         // Load it up.
                         $translations = (include $path);
                         if (is_array($translations)) {
                             // If this is framework data and we're not on en_us, then do some special processing.
                             if (strpos($path, 'framework/i18n/data') !== false && $file !== 'en_us') {
                                 $translations = $this->_processFrameworkData($file);
                             }
                             $this->_translations[$language] = array_merge($this->_translations[$language], $translations);
                         }
                     }
                 }
             }
         }
     }
     return $this->_translations[$language];
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:65,代码来源:PhpMessageSource.php


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