#!/usr/bin/perl -w # # This script converts and updates revision comments in translations. # It will automatically replace revision comments for 'original documents' # with revision comments for 'translated documents'. # This script only supports SVN style revision marks. # use Getopt::Std; use File::Find; $opt_h = $opt_u = $opt_v = 0; getopts('huv'); # You may set this to your default language code $lang = shift || "pl"; sub usage { printf <] -h print this help message. -u update the revision for the translated document to the revision number in the original document (use only after having made sure there are no changes in content for the listed documents). -v be verbose. Current is '%s'. HERE exit 0; } sub convert { my ($plfname, $plrev) = (@_); my $transtext = ''; open (FILE, "< $plfname"); while () { if (/)/$1 original version: $plrev untranslated $3/; } $transtext .= $_; } close (FILE); warn "Writing $plfname\n" if $opt_v; open (FILE, "> $plfname"); print FILE $transtext; close (FILE); } sub update { my ($plfname, $plrev, $enrev) = (@_); my $transtext = ''; open (FILE, "< $plfname"); while () { if (/)/$1$enrev$3/; } $transtext .= $_; } close (FILE); warn "Writing $plfname\n" if $opt_v; open (FILE, "> $plfname"); print FILE $transtext; close (FILE); } sub getrev { my ($plfname, $enfname) = (@_); my ($plrev, $enrev) = (0, 0); my ($notconverted, $untrans) = (0, 0); warn "checking $plfname:\n" if $opt_v; open FILE, $plfname or warn "$plfname: $!\n" and return; while () { if (//) { $plrev = $1; last; } if (//) { $plrev = $1; $untrans = 1; last; } # Also check for revision comments of original documents if (/