#!/usr/bin/perl # Copyright 13th. October 2008, Cotman University # http://www.cotmanuniversity.com # Created by Dr. Peter Kjeldsen # Department for Computational Linguistics # Conversion of CVS format to Trados Text TM format # File name: wftrados.pl # # Instructions # Change name of input file, source and target language # as required. # Run from command prompt perl wftrados.pl # # Setting up formated variable for handling date and time ($sec, $min, $hour, $mday, $mon, $year) = localtime(time); $mon++; $year+= 1900; $hour = sprintf("%02d", $hour); $min = sprintf("%02d", $min); $sec = sprintf("%02d", $sec); # Opening input file open (TXT, "; close (TXT); #Throwing away the first line of the WF TM in the array shift @text; # Opening/creating output file open (TM, ">>lingualizerWFtradosTM.txt") or die ("Cannot open file!"); # Creating header for output file $header = '' . "\n"; print TM $header; print TM "\n"; print TM "\n"; print TM "\n"; # Looping through input file content line by line foreach $lines(@text) { # Splitting line content and creating translation units @line = split (/\t/, $lines); $srclang = $line[3]; $source = $line[4]; $tgtlang = $line[5]; $target = $line[6]; # Creating the source element of the translation unit $SourceFull = '' . $source; # Creating the target element of the translation unit $TargetFull = '' . $target; print TM "\n"; print TM " $mday" . "$mon" . "$year, $hour:$min:$sec" . "\n"; print TM "Lingualizer\n"; print TM "$SourceFull\n"; print TM "$TargetFull\n"; print TM "\n"; } # Closing output file close (TM);