<?php
require __DIR__ . '/../vendor/autoload.php';

$app = require_once __DIR__ . '/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

use Illuminate\Support\Facades\DB;

$file = $argv[1] ?? 'fp';

echo "Checking translations for file: $file\n";

$translationsCount = DB::table('translations')->where('file', $file)->count();
$translationsSample = DB::table('translations')->where('file', $file)->limit(5)->get();

$activeLanguages = DB::table('active_languages')->where('type', $file)->get();
$activeLanguagesCount = $activeLanguages->count();

echo "translations.count = $translationsCount\n";
echo "active_languages.count = $activeLanguagesCount\n";
echo "active_languages rows:\n";
foreach ($activeLanguages as $al) {
    echo " - iso={$al->iso} active={$al->active} type={$al->type}\n";
}

echo "sample translations:\n";
foreach ($translationsSample as $t) {
    echo " - key={$t->keycode} file={$t->file} value=" . substr($t->value,0,80) . "...\n";
}

exit(0);
