#!/usr/bin/perl

# (c) 2005 Christoph Thielecke <crissi99@gmx.de>
# Version 0.1

  use Petal;
  use Petal::TranslationService::Gettext;



  $arg1 = shift;
  $arg2 = shift;
  $arg3 = shift;
  $arg4 = shift;
#   print "1: $arg1, 2: $arg2, 3: $arg3, 4: $arg4\n";


  $lang=$arg1;
  $pub_dir=$arg2;
  $infile=$arg3;
  $outfile=$arg4;
  my $translation_service = new Petal::TranslationService::Gettext (
      locale_dir  => "$pub_dir/locale",
      target_lang => $lang,
  );

  my $template = new Petal (
      file => $infile,
      translation_service => $translation_service
  );
  #print "outfile: $pub_dir/$lang/$outfile\n";
  open(FILE,"> $pub_dir/$lang/$outfile") or die "Fehler beim Oeffnen zum Schreiben von '$file': !\n";
  print FILE $template->process ();
  close (FILE);
