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


PHP Lang::getHints方法代码示例

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


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

示例1: handle

 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     // get paths of registered namespace hints
     // e.g user in @lang('user::myview') resolving to app/Modules/User/Resources
     $resDirs = Config::get('langcheck.usehints') ? Lang::getHints() : array();
     $resDirs[base_path() . '/resources/lang'] = 'app';
     // check each resource directory
     foreach ($resDirs as $path => $hint) {
         // skip vendor directories
         if (Config::get('langcheck.skipvendor') && strpos($path, "vendor/") !== false) {
             continue;
         }
         // generate path relative to project root
         $shortPath = substr($path, strlen(base_path() . '/'));
         $this->info("Checking '{$shortPath}'...");
         // load translation files into arrays
         $langDirs = File::directories($path);
         $languageData = array();
         foreach ($langDirs as $langDir) {
             $langCode = basename($langDir);
             $arrays = File::files($langDir);
             foreach ($arrays as $file) {
                 $fileName = basename($file);
                 $languageData[$langCode][$fileName] = File::getRequire($file);
             }
         }
         // compare language arrays with each other and find missing entries
         foreach ($languageData as $langCodeA => $langArraysA) {
             foreach ($langArraysA as $fileNameA => $langArrayA) {
                 foreach ($languageData as $langCodeB => $langArraysB) {
                     if ($langCodeA == $langCodeB) {
                         continue;
                     }
                     if (array_key_exists($fileNameA, $langArraysB)) {
                         $result = $this->array_diff_key_recursive($langArrayA, $langArraysB[$fileNameA]);
                         if (!empty($result)) {
                             $keys = implode($this->arrayKeysRecursive($result), ', ');
                             $this->error(" * File '{$fileNameA}':");
                             $this->error("   - Locale '{$langCodeB}' missing [{$keys}] existing in locale '{$langCodeA}'");
                         }
                     } else {
                         $this->error(" * File '{$fileNameA}' existing in locale '{$langCodeA}' is missing for locale '{$langCodeB}'");
                     }
                 }
             }
         }
         $this->info('');
     }
 }
开发者ID:ottowayne,项目名称:laravel-langcheck,代码行数:54,代码来源:LangCheckCommand.php


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