/[d-i]/trunk/installer/doc/manual/scripts/rev-update
ViewVC logotype

Contents of /trunk/installer/doc/manual/scripts/rev-update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15141 - (hide annotations) (download)
Mon May 10 21:05:52 2004 UTC (9 years ago) by fjpop-guest
Original Path: trunk/installer/doc/manual/rev-update
File size: 3502 byte(s)
Manual: improved revision tracking for translations
1 fjpop-guest 15141 #!/usr/bin/perl -w
2    
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.
9    
10     # Note: only use the "-u" option after you have made sure there are no
11     # changes in content for the listed documents.
12    
13     # SYNOPSIS:
14     # ./rev-update [-u] [-v] [lang]
15     #
16     # (uses $lang set below if lang is not given on commandline)
17    
18     use Getopt::Std;
19     use File::Find;
20     $opt_u = $opt_v = 0;
21     getopts('uvV');
22     # You may set this to your default language code
23     $lang = shift || "pl";
24    
25     sub convert
26     {
27     my ($plfname, $plrev) = (@_);
28     my $transtext = '';
29     open (FILE, "< $plfname");
30     while (<FILE>) {
31     if (/<!--\s*\$Id: \S+ (\d+) /) {
32     s/(<!--)(.*)(-->)/$1 original version: $plrev untranslated $3/;
33     }
34     $transtext .= $_;
35     }
36     close (FILE);
37     warn "Writing $plfname\n" if $opt_v;
38     open (FILE, "> $plfname");
39     print FILE $transtext;
40     close (FILE);
41     }
42    
43     sub update
44     {
45     my ($plfname, $plrev, $enrev) = (@_);
46     my $transtext = '';
47     open (FILE, "< $plfname");
48     while (<FILE>) {
49     if (/<!--\s*original version/) {
50     s/(<!--.*\s)($plrev)(\s.*-->)/$1$enrev$3/;
51     }
52     $transtext .= $_;
53     }
54     close (FILE);
55     warn "Writing $plfname\n" if $opt_v;
56     open (FILE, "> $plfname");
57     print FILE $transtext;
58     close (FILE);
59     }
60    
61     sub getrev
62     {
63     my ($plfname, $enfname) = (@_);
64     my ($plrev, $enrev) = (0, 0);
65     my ($notconverted, $untrans) = (0, 0);
66    
67     warn "checking $plfname:\n" if $opt_v;
68     open FILE, $plfname or warn "$plfname: $!\n" and return;
69     while (<FILE>) {
70     if (/<!--\s*original version\D*(\d+)\s*-->/) {
71     $plrev = $1;
72     last;
73     }
74     if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
75     $plrev = $1;
76     $untrans = 1;
77     last;
78     }
79     # Also check for revision comments of original documents
80     if (/<!--\s*\$Id: \S+ (\d+) /) {
81     $plrev = $1;
82     $notconverted = 1;
83     $untrans = 1;
84     last;
85     }
86     }
87     warn "checking $enfname:\n" if $opt_v;
88     open FILE, $enfname or warn "$enfname: $!\n" and return;
89     while (<FILE>) {
90     if (/<!--\s*\$Id: \S+ (\d+) /) {
91     $enrev = $1;
92     last;
93     }
94     }
95     close FILE;
96     warn "failed to find revision for $plfname\n" unless $plrev;
97     warn "failed to find revision for $enfname\n" unless $enrev;
98     if ($notconverted) {
99     warn "$plfname: converting revision comment\n";
100     warn " document marked 'untranslated'\n";
101     convert($plfname, $plrev);
102     }
103     return ($plrev, $enrev, $untrans);
104     }
105    
106     sub checkrev
107     {
108     my ($plfname, $enfname) = (@_);
109     my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
110     $plrev and $enrev or return;
111     if ( "$plrev" ne "$enrev" ) {
112     if ($untrans) {
113     print "$enfname : $plrev -> $enrev (untranslated)\n";
114     } else {
115     print "$enfname : $plrev -> $enrev\n";
116     }
117     if ($opt_u) {
118     update($plfname, $plrev, $enrev);
119     print "$plfname : revision updated\n";
120     }
121     }
122     }
123    
124     sub process
125     {
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);
131     }
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");

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5