#!/usr/bin/php -q
<?php
	/**************************************************************************\
	* eGroupWare - phpldapadmin                                                *
	* http://www.eGroupWare.org                                                *
	* --------------------------------------------                             *
	*  This program is free software; you can redistribute it and/or modify it *
	*  under the terms of the GNU General Public License as published by the   *
	*  Free Software Foundation; either version 2 of the License, or (at your  *
	*  option) any later version.                                              *
	\**************************************************************************/

	/* $Id: lang2eGW,v 1.1 2003/11/11 12:26:46 ralfbecker Exp $ */

	switch($_SERVER['argv'][1])
	{
		case 'german':
			$short = 'de';
			break;
		case 'english':
			$short = 'en';
			break;
		case 'french':
			$short = 'fr';
			break;
		case '':
			break;
		default:
			echo "Unknown language '".$_SERVER['argv'][1]."' !!!\n";
			exit (2);
	}
	$file = $_SERVER['argv'][1];
	if ($file && !strstr($file,'.php'))
	{
		$file .= '.php';
	}
	if (!$_SERVER['argc'] || !file_exists($file))
	{
		echo "Usage: lang2eGW {english|german|french}.php\n";
		exit (1);
	}
	include($file);

	foreach($lang as $message_id => $translation)
	{
		$eGW .= "$message_id\tphpldapadmin\t$short\t$translation\n";
	}	
	if (!($fp = fopen($f="../setup/phpgw_$short.lang",'w')))
	{
		echo "Can't open '$f' for writeing !!!\n";
	}
	fwrite ($fp,$eGW);
	fclose ($fp);

	echo count($lang)." phrases written to '$f'\n";
	exit(0);
