3
# This script converts and updates revision comments in translations.
4
# It will automatically replace revision comments for 'original documents'
5
# with revision comments for 'translated documents'.
6
# When called with "-u" option, it will also update the revision for the
7
# translated document to the revision number in the original document.
8
# This script only supports SVN style revision marks.
10
# Note: only use the "-u" option after you have made sure there are no
11
# changes in content for the listed documents.
14
# ./rev-update [-u] [-v] [lang]
16
# (uses $lang set below if lang is not given on commandline)
22
# You may set this to your default language code
23
$lang = shift || "pl";
27
my ($plfname, $plrev) = (@_);
29
open (FILE, "< $plfname");
31
if (/<!--\s*\$Id: \S+ (\d+) /) {
32
s/(<!--)(.*)(-->)/$1 original version: $plrev untranslated $3/;
37
warn "Writing $plfname\n" if $opt_v;
38
open (FILE, "> $plfname");
39
print FILE $transtext;
45
my ($plfname, $plrev, $enrev) = (@_);
47
open (FILE, "< $plfname");
49
if (/<!--\s*original version/) {
50
s/(<!--.*\s)($plrev)(\s.*-->)/$1$enrev$3/;
55
warn "Writing $plfname\n" if $opt_v;
56
open (FILE, "> $plfname");
57
print FILE $transtext;
63
my ($plfname, $enfname) = (@_);
64
my ($plrev, $enrev) = (0, 0);
65
my ($notconverted, $untrans) = (0, 0);
67
warn "checking $plfname:\n" if $opt_v;
68
open FILE, $plfname or warn "$plfname: $!\n" and return;
70
if (/<!--\s*original version\D*(\d+)\s*-->/) {
74
if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
79
# Also check for revision comments of original documents
80
if (/<!--\s*\$Id: \S+ (\d+) /) {
87
warn "checking $enfname:\n" if $opt_v;
88
open FILE, $enfname or warn "$enfname: $!\n" and return;
90
if (/<!--\s*\$Id: \S+ (\d+) /) {
96
warn "failed to find revision for $plfname\n" unless $plrev;
97
warn "failed to find revision for $enfname\n" unless $enrev;
99
warn "$plfname: converting revision comment\n";
100
warn " document marked 'untranslated'\n";
101
convert($plfname, $plrev);
103
return ($plrev, $enrev, $untrans);
108
my ($plfname, $enfname) = (@_);
109
my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
110
$plrev and $enrev or return;
111
if ( "$plrev" ne "$enrev" ) {
113
print "$enfname : $plrev -> $enrev (untranslated)\n";
115
print "$enfname : $plrev -> $enrev\n";
118
update($plfname, $plrev, $enrev);
119
print "$plfname : revision updated\n";
126
my $enfname = $File::Find::name;
127
return unless $enfname =~ m/\.xml$/;
128
my $plfname = $enfname;
129
$plfname =~ s,^en/,$lang/,;
130
checkrev($plfname, $enfname);
132
File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en');
133
#checkrev("build/install.$lang.xml", "build/install.en.xml");
134
#checkdiff("release-notes.$lang.sgml","release-notes.sgml");
135
#checkdiff("index.$lang.html.m4","index.en.html.m4");
136
#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");