<?php
$json = file_get_contents('lang/ar.json');
$lines = explode("\n", $json);
$keys = [];
$duplicates = [];

foreach ($lines as $i => $line) {
    if (preg_match('/^\s*"([^"]+)"\s*:/', $line, $matches)) {
        $key = $matches[1];
        if (isset($keys[$key])) {
            if (!isset($duplicates[$key])) {
                $duplicates[$key] = [$keys[$key]];
            }
            $duplicates[$key][] = $i + 1;
        }
        $keys[$key] = $i + 1;
    }
}

foreach ($duplicates as $key => $line_numbers) {
    echo "Key: '$key' found at lines: " . implode(", ", $line_numbers) . "\n";
    foreach ($line_numbers as $ln) {
        echo "  $ln: " . trim($lines[$ln-1]) . "\n";
    }
}
