#!/usr/bin/perl

my %lex = ('Main' => 'Main');

use DBI;
use CGI;

eval require "../../etc/admin.conf";
if ( $@ ) {
    print $lex{Error}. " $@<br>\n";
    die $lex{Error}. " $@\n";
}

my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);


my $sth = $dbh->prepare("select phrase from xlat_phrase");
$sth->execute;
if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }

my %phrase = ();

while ( my $phrase = $sth->fetchrow ) {
    $phrase{$phrase} = 1;
} 

# Now Get Translations
my $sth = $dbh->prepare("select phrase from xlat_lang");
$sth->execute;
if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }

my %trans = ();
while ( my $phrase = $sth->fetchrow ) {
    $trans{$phrase} = 1;
} 

# Loop through phrases and remove matching values from trans
my $count = 1;
foreach my $phrase ( keys %phrase ) {
    if ( $trans{$phrase} ) { 
	delete $trans{$phrase}; 
    } else {
	print "$count: No Trans $phrase\n";
	$count++;
    }
}

print "\n\n";

$sth = $dbh->prepare("delete from xlat_lang where phrase = ?");

# Now print out what's left in translation
$count = 1;
foreach my $phrase ( keys %trans ) {
    print "$count: $phrase\n";
    $count++;

    $sth->execute( $phrase );
    if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }

}





