#!/usr/bin/perl

$path="/usr/*";
$string1="[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n";
$menu="/usr/share/applnk/Streaming/";

print "This little program finds all files which could be translated...\n\n";

print <<End_of_Eintrag
It is quite easy to translate the files for the StreamBOX-CD: 
Open the current file with a ordinary texteditor & look what is in there:

The first part is a big chunk of data where all the things are in the format

\$BLA01="Blub"
\$BLA02="Blub"

If you want to add another language you just have to add the same strings,
in the same order, with no lines with other stuff in between! Or just edit
the english things and replace them with the new strings.

The second part consists of lines with either Name, GenericName or Comment at 
the beginning

So Name is what appears in the Menu of the StreamBOX-CD, the GenericName how
you would call the program, and the comment is a one sentence description what
the programm does. For a translation to french to e.g.

Name[fr]=BLALA
GenericName[fr]=BlULBEL
Comment[fr]=testettas

fr=french, es=spanish, it=italian, 

if you need support by translating, please send an email to ilja\@streambox.org

End_of_Eintrag

;


$command="find $path -exec agrep -l '$string1' {} \\;";
@files=`$command`;

print "\n\n\n -------- here comes the first part --------- \n\n\n\n";

foreach $datei (@files)
	{
	&pastestrings($datei);
	}

print "\n\n\n -------- here comes the second part --------- \n\n\n\n";

$command="for i in $menu\*; do echo ------------ \$i -----------; cat \$i | agrep '(Name|^Comment)'; done;";
system($command);
# print "\n\n\n$command\n\n\n";

sub pastestrings
{
$dateiname=@_[0];
chomp($dateiname);

print "------------------------ START -------------------------\n";
print "$dateiname \n";
print "------------------------ START -------------------------\n\n\n\n";

open (FILE,"<$dateiname");
@content=<FILE>;
close (FILE);
$alert=0;$num=1;
foreach $line (@content)
	{
		if ($line=~/case \"\$LANGUAGE\" in/){$alert=1; print "#### Line # $num ####\n";}
		if ($alert==1) {print $line;}
		if ($line=~/esac/){$alert=0;}
		$num++;
	}

print "------------------------ STOP -------------------------\n";
print "$dateiname \n";
print "------------------------ STOP -------------------------\n\n\n\n";

}
