#!/usr/bin/perl -w

if (@ARGV != 1)
{
  die ("Input argument must be the name of a translation file (FILENAME.ts)");
}

open (FH, "<$ARGV[0]") or die "unable to open $$ARGV[0]";

while ($_ = <FH>) 
{
  if (m|<translation[^>]*>(.*)</translation>|)
  {
    $str = $1;
    $str =~ s/&amp;/&/g;
    $str =~ s/&lt;/</g;
    $str =~ s/&gt;/>/g;
    $str =~ s/&quot;/"/g;
    $str =~ s/&apos;/'/g;
    @words = split (/\s+/, $str);
    foreach $word (@words)
    {
      $db{$word} = 1;
    }
  }
}

close (FH);

foreach $word (sort (keys (%db)))
{
  print $word, "\n";
}
