#!/usr/bin/perl
  #**************************************************************************#
  # phpGroupWare                                                             #
  # http://www.phpgroupware.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: splitlang.pl.txt 6999 2001-07-30 15:59:25Z seek3r $ #
 
	# splitlang.pl (c) 2001 Miles Lott
	# split common phpgw_LANG.lang files into seperate files for each app
	# and language.  Requires perl and the source lang files and a dir named
	# 'tmp' in the current working dir.  May only work in bash also.  Makes
	# system calls to mkdir and cat.

	$dir = opendir(DIR,'.');
	#@files = grep { /^phpgw_/ && -f "$dir/$_" } readdir(DIR);
	@files = grep { /phpgw/ } readdir(DIR);
	closedir(DIR);

	for $i (0..$#files)
	{
		# Run through each lang file
		$_ = $files[$i];
		print "Working on: " . $_ . "\n";
		open(FILE,$_);
		while (<FILE>)
		{
			chomp $_;
			($key,$appname,$lang,$content) = split("\t",$_);
			if(!stat("tmp/$appname/setup"))
			{
				my $mkdir = "mkdir -p tmp/$appname/setup";
				system($mkdir);
			}
			my $cmd = 'echo "'. $_ . '" >> tmp/' . $appname . "/setup/phpgw_" . $lang . ".lang";
			system($cmd);
			#print $appname . "\n";
		}
		close(FILE);
	}
