#!/usr/bin/perl -w

use strict;

our %langs = (
	      'ca' => 'catalan',
	      'cs' => 'czech',
	      'da' => 'danish',
	      'de' => 'german',
	      'es' => 'spanish',
	      'fi' => 'finnish',
	      'fr' => 'french',
	      'el_GR' => 'greek',
	      'hu' => 'hungarian',
	      'it' => 'italian',
	      'nl' => 'dutch',
	      'no' => 'norwegian',
	      'pl' => 'polish',
	      'pt_BR' => 'brazilian',
	      'sk' => 'slovak',
	      'sv' => 'swedish',
	     );

our @locales;
if (@ARGV == 0) {
  @locales = keys %langs;
} else {
  @locales = @ARGV;
}

foreach my $key (@locales) {
  print STDERR " $langs{$key} -> $key:\n";
  system ("./utils/wml2po.pl data/translations/" . $langs{$key} .
	  ".cfg po/$key/wesnoth.po > out-$key.log 2> err-$key.log")
    and print STDERR "translation1 ended in error !\n";
  system ("./utils/wml2po.pl data/translations/" . $langs{$key} .
	  ".cfg po/$key/wesnoth-editor.po > out-$key-ed.log 2> err-$key-ed.log")
    and print STDERR "translation2 ended in error !\n";
  system ("grep FINAL err-$key.log");
}
