49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Extract unused translation keys from en.json for review
|
|
*/
|
|
|
|
// Run the find-unused command and capture output
|
|
exec('php artisan ai-translator:find-unused --format=table --show-files --no-interaction 2>&1', $output);
|
|
|
|
$inEnJson = false;
|
|
$unusedKeys = [];
|
|
|
|
foreach ($output as $line) {
|
|
// Check if we're in the en.json section
|
|
if (strpos($line, 'en.json:') !== false) {
|
|
$inEnJson = true;
|
|
continue;
|
|
}
|
|
|
|
// Check if we've moved to another file
|
|
if ($inEnJson && preg_match('/^\s*[a-z\-]+\.php:/', $line)) {
|
|
break;
|
|
}
|
|
|
|
// Extract the key if we're in en.json section
|
|
if ($inEnJson && preg_match('/│\s+([^\s│]+)\s+│/', $line, $matches)) {
|
|
$unusedKeys[] = $matches[1];
|
|
}
|
|
}
|
|
|
|
echo "=== UNUSED TRANSLATION KEYS IN en.json ===\n";
|
|
echo "Total: " . count($unusedKeys) . " keys\n\n";
|
|
|
|
// Save to file
|
|
file_put_contents('/tmp/unused-en-keys-list.txt', implode("\n", $unusedKeys));
|
|
|
|
// Show first 50 for preview
|
|
echo "First 50 unused keys:\n";
|
|
echo str_repeat('-', 80) . "\n";
|
|
foreach (array_slice($unusedKeys, 0, 50) as $key) {
|
|
echo " - " . $key . "\n";
|
|
}
|
|
|
|
if (count($unusedKeys) > 50) {
|
|
echo "\n... and " . (count($unusedKeys) - 50) . " more.\n";
|
|
}
|
|
|
|
echo "\nFull list saved to: /tmp/unused-en-keys-list.txt\n";
|