40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class CheckTranslations extends Command
|
|
{
|
|
protected $signature = 'translations:check';
|
|
|
|
public function handle()
|
|
{
|
|
$baseLanguage = config('app.fallback_locale');
|
|
$languages = config('app.locales');
|
|
|
|
$baseFiles = File::files(resource_path("lang/{$baseLanguage}"));
|
|
|
|
foreach ($baseFiles as $file) {
|
|
$filename = $file->getFilename();
|
|
$baseTranslations = require $file->getPathname();
|
|
|
|
foreach ($languages as $language) {
|
|
$path = resource_path("lang/{$language}/{$filename}");
|
|
|
|
if (!File::exists($path)) {
|
|
$this->error("Missing file: {$language}/{$filename}");
|
|
continue;
|
|
}
|
|
|
|
$translations = require $path;
|
|
$missingKeys = array_diff_key($baseTranslations, $translations);
|
|
|
|
if (!empty($missingKeys)) {
|
|
$this->warn("Missing keys in {$language}/{$filename}: " . implode(', ', array_keys($missingKeys)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |