96 lines
3.1 KiB
PHP
96 lines
3.1 KiB
PHP
<?php
|
|
require __DIR__.'/vendor/autoload.php';
|
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
|
|
use App\Models\SiteTranslation;
|
|
use App\Models\Translation;
|
|
use App\Models\Language;
|
|
|
|
echo "=== Language Table ===\n";
|
|
foreach (Language::all() as $lang) {
|
|
echo "- {$lang->code}: {$lang->name} (Active: {$lang->is_active}, Default: {$lang->is_default})\n";
|
|
}
|
|
|
|
echo "\n=== Site Translations Table ===\n";
|
|
$siteTranslations = SiteTranslation::all();
|
|
$totalSite = $siteTranslations->count();
|
|
$missingEnSite = 0;
|
|
$missingEnKeys = [];
|
|
|
|
foreach ($siteTranslations as $st) {
|
|
$trans = $st->translations ?? [];
|
|
if (!isset($trans['en']) || empty($trans['en'])) {
|
|
$missingEnSite++;
|
|
if (count($missingEnKeys) < 10) {
|
|
$missingEnKeys[] = [
|
|
'id' => $st->id,
|
|
'key' => $st->key,
|
|
'translations' => $trans
|
|
];
|
|
}
|
|
}
|
|
}
|
|
echo "Total Site Translations: {$totalSite}\n";
|
|
echo "Missing 'en' translation in Site Translations: {$missingEnSite}\n";
|
|
if (!empty($missingEnKeys)) {
|
|
echo "Sample missing 'en' Site Translations:\n";
|
|
print_r($missingEnKeys);
|
|
}
|
|
|
|
echo "\n=== Translations Table ===\n";
|
|
$translations = Translation::all();
|
|
$totalTrans = $translations->count();
|
|
echo "Total translations: {$totalTrans}\n";
|
|
|
|
$trTranslations = Translation::where('language_code', 'tr')->get();
|
|
$enTranslations = Translation::where('language_code', 'en')->get();
|
|
|
|
echo "TR Translations count: " . $trTranslations->count() . "\n";
|
|
echo "EN Translations count: " . $enTranslations->count() . "\n";
|
|
|
|
// Find translatable models that have TR but missing EN
|
|
$trByModel = [];
|
|
foreach ($trTranslations as $t) {
|
|
$key = "{$t->translatable_type}:{$t->translatable_id}:{$t->field_name}";
|
|
$trByModel[$key] = $t;
|
|
}
|
|
|
|
$enByModel = [];
|
|
foreach ($enTranslations as $t) {
|
|
$key = "{$t->translatable_type}:{$t->translatable_id}:{$t->field_name}";
|
|
$enByModel[$key] = $t;
|
|
}
|
|
|
|
$missingEnTranslations = [];
|
|
foreach ($trByModel as $key => $t) {
|
|
if (!isset($enByModel[$key])) {
|
|
$missingEnTranslations[] = [
|
|
'key' => $key,
|
|
'tr_value' => $t->field_value
|
|
];
|
|
} else {
|
|
// Also check if EN value is identical to TR value and might need translation
|
|
$enVal = $enByModel[$key]->field_value;
|
|
if ($enVal === $t->field_value && preg_match('/[a-zA-ZğüşıöçĞÜŞİÖÇ]/', $t->field_value)) {
|
|
// Check if it's identical
|
|
$identicalEnTranslations[] = [
|
|
'key' => $key,
|
|
'value' => $t->field_value
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
echo "Missing 'en' translations: " . count($missingEnTranslations) . "\n";
|
|
if (!empty($missingEnTranslations)) {
|
|
echo "Sample missing EN translations:\n";
|
|
print_r(array_slice($missingEnTranslations, 0, 10));
|
|
}
|
|
|
|
echo "Identical TR and EN translations (possible untranslated): " . count($identicalEnTranslations ?? []) . "\n";
|
|
if (!empty($identicalEnTranslations)) {
|
|
echo "Sample identical translations:\n";
|
|
print_r(array_slice($identicalEnTranslations, 0, 10));
|
|
}
|