Return to Snippet

Revision: 25608
at April 2, 2010 07:45 by paramah


Initial Code
#!/opt/local/bin/perl

use strict;
use warnings;
use Cwd;
use List::MoreUtils qw/ uniq /;

use File::Find;

my $file_pattern  =$ARGV[2];
my $path = cwd."/".$ARGV[0];
my $trans_file = cwd."/".$ARGV[1];
my @out;
my @uniq;
my $tlumaczenia = 0;
my $xml;

find(\&translate_check, $path);

sub translate_check
{
	my $file = $File::Find::name;
	return unless $file =~ /.svn/;
	open F, $file or print "couldn't open $file\n" && return;
	while (<F>) 
	{
		if (/(.*)_\('(.*)'\)(.*)/) 
		{
			    push(@out, $2);
		}
	}
	close F;
}

open T, $trans_file or print "couldn't open $trans_file\n";
while (<T>)
{
	@uniq = uniq @out;
	if(/\<tu tuid='(.*)'\>/)
	{
		foreach ( @uniq ) 
		{
			$tlumaczenia = 0;
			if ($1 eq $_)
			{
				$tlumaczenia = 1;
				last;
			}
		}
		print "[.] ".$1;
		if($tlumaczenia eq '1') 
		{ 
			print "\t[OK]"; 	
		}
		else
		{
			$xml .= "
			<tu tuid='".$1."'>
				<tuv xml:lang=\"en\">
					<seg></seg>
				</tuv>
				<tuv xml:lang=\"de\">
					<seg></seg>
				</tuv>
				<tuv xml:lang=\"pl\">
					<seg></seg>
				</tuv>
			</tu>\n\n\n"
		}
		print "\n";
	}
}
print $xml;
close T;

Initial URL

                                

Initial Description

                                

Initial Title
Make translation for Zend_translate via Perl script

Initial Tags
textmate, xml, perl

Initial Language
Other