當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。