本文整理汇总了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('');
}
}