chiark / gitweb /
translation status checking tool, based on documentation/doc-check
[developers-reference.git] / translation-status
1 #!/usr/bin/perl -w
2
3 # This script checks if the translations of the documents are up to date.
4 # When called with "-d" option, it also prints what has changed in the
5 # original since last translation
6
7 # SYNOPSIS:
8 #             ./doc-check [-d] [-v] [-V] [lang]
9 #
10 #       (uses $lang set below if lang is not given on commandline)
11
12 use Getopt::Std;
13 $opt_d = $opt_v = $opt_V = 0;
14 getopts('dvV');
15 # You may set this to your default language code
16 $lang = shift || "pl";
17
18 sub checkdiff
19 {
20         my ($plfname, $enfname) = (@_);
21         my ($plrev, $enrev) = getrev($plfname, $enfname);
22         $plrev and $enrev or return;
23         if ( "$plrev" ne "$enrev" ) {
24                 if ($opt_d) {
25                         my $s = "cvs diff -b -u -r $plrev -r $enrev $enfname";
26                         warn "running $s:\n" if ($opt_V);
27                         system($s);
28                 } else {
29                         print "$enfname : $plrev -> $enrev\n";
30                 }
31         }
32 }
33
34 sub getrev
35 {
36         my ($plfname, $enfname) = (@_);
37         my ($plrev, $enrev) = (0, 0);
38
39         warn "checking $plfname:\n" if $opt_v;
40         open FILE, $plfname or warn "$plfname: $!\n" and return;
41         while (<FILE>) {
42                 if (/<!--\s*original version\D*([\d\.]+)\s*-->/) {
43                         $plrev = $1;
44                         last;
45                 }
46                 if (/<!--\s*original document: en\/\S+, revision ([\d\.]+)\s*-->/) {
47                         $plrev = $1;
48                         last;
49                 }
50         }
51         warn "checking $enfname:\n" if $opt_v;
52         open FILE, $enfname or warn "$enfname: $!\n" and return;
53         while (<FILE>) {
54                 if (/\$Id: [^\s]+ ([\d\.]+) .* Exp \$/) {
55                         $enrev = $1;
56                         last;
57                 }
58                 if (/\$Revision: ([\d\.]+) \$/) {
59                         $enrev = $1;
60                         last;
61                 }
62         }
63         close FILE;
64         warn "failed to find revision for $plfname\n" unless $plrev;
65         warn "failed to find revision for $enfname\n" unless $enrev;
66         return ($plrev, $enrev);
67 }
68
69 @subdocs = ("welcome", "hardware", "preparing", "inst-methods", "rescue-boot", "partitioning", "kernel", "boot-new", "post-install", "tech-info", "appendix", "administrivia");
70
71 foreach $doc (@subdocs) {
72         my $plfname = "$lang/" . "$doc" . ".sgml";
73         my $enfname = "en/" . "$doc" . ".sgml";
74         checkdiff($plfname, $enfname);
75 }
76 checkdiff("install.$lang.sgml", "install.sgml");
77 checkdiff("release-notes.$lang.sgml","release-notes.sgml");
78 checkdiff("index.$lang.html.m4","index.en.html.m4");
79 checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");