~ubuntu-branches/ubuntu/vivid/installation-guide/vivid-proposed

« back to all changes in this revision

Viewing changes to scripts/doc-check

  • Committer: Bazaar Package Importer
  • Author(s): Frans Pop
  • Date: 2005-10-25 17:37:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051025173725-aq0bm11be7bfd7rw
Tags: 20051025
* Mention in copyright that full GPL is included in the manual.
  Closes: #334925
* Register installed documents with doc-base.
* Minor updates in English text and translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# If the "-r" option is used with the "-d" option, the diff will be taken
 
7
# against the revision number specified with the -r option instead of
 
8
# the latest revision of the English original.
 
9
# When called with "-s" option, it also shows all files that are marked
 
10
# untranslated.
 
11
 
 
12
# SYNOPSIS:
 
13
#             ./doc-check [-d] [-r <revision>] [-s] [-v] [-V] [lang]
 
14
#
 
15
#       (uses $lang set below if lang is not given on commandline)
 
16
 
 
17
use Getopt::Std;
 
18
use File::Find;
 
19
$opt_d = $opt_r = $opt_s = $opt_v = $opt_V = 0;
 
20
getopts('r:dsvV');
 
21
# You may set this to your default language code
 
22
$lang = shift || "pl";
 
23
if ($opt_r and $opt_r !~ /[0-9]+/) {
 
24
        warn "Please enter a revision number for parameter -r.\n";
 
25
        exit 1
 
26
}
 
27
 
 
28
sub checkdiff
 
29
{
 
30
        my ($plfname, $enfname) = (@_);
 
31
        my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
 
32
        $plrev and $enrev or return;
 
33
        if ( "$plrev" ne "$enrev" ) {
 
34
                if ($opt_d and $opt_r and $opt_r < $enrev) {
 
35
                        $enrev = $opt_r;
 
36
                }
 
37
                if ($untrans) {
 
38
                        print "$enfname : $plrev -> $enrev (untranslated)\n";
 
39
                } else {
 
40
                        print "$enfname : $plrev -> $enrev\n";
 
41
                }
 
42
                if ($opt_d) {
 
43
                        my $s = "svn diff -r $plrev:$enrev $enfname";
 
44
                        warn "running $s:\n" if ($opt_V);
 
45
                        system($s);
 
46
                }
 
47
        } else {
 
48
                if ($untrans && $opt_s) {
 
49
                        print "$plfname: untranslated\n";
 
50
                }
 
51
        }
 
52
}
 
53
 
 
54
sub getrev
 
55
{
 
56
        my ($plfname, $enfname) = (@_);
 
57
        my ($plrev, $enrev, $untrans, $notconverted) = (0, 0, 0, 0);
 
58
 
 
59
        warn "checking $plfname:\n" if $opt_v;
 
60
        open FILE, $plfname or warn "$plfname: $!\n" and return;
 
61
        while (<FILE>) {
 
62
                if (/<!--\s*original version\D*([\d\.]+)\s*-->/) {
 
63
                        $plrev = $1;
 
64
                        last;
 
65
                }
 
66
                if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
 
67
                        $plrev = $1;
 
68
                        $untrans = 1;
 
69
                        last;
 
70
                }
 
71
                # Also check for revision comments of original documents
 
72
                if (/<!--\s*\$Id: \S+ (\d+) /) {
 
73
                        $plrev = $1;
 
74
                        $notconverted = 1;
 
75
                        $untrans = 1;
 
76
                        last;
 
77
                }
 
78
                # Also support CVS style revision comments (depreciated)
 
79
                if (/<!--\s*original document: en\/\S+, revision ([\d\.]+)\s*-->/) {
 
80
                        $plrev = $1;
 
81
                        last;
 
82
                }
 
83
        }
 
84
        warn "checking $enfname:\n" if $opt_v;
 
85
        open FILE, $enfname or warn "$enfname: $!\n" and return;
 
86
        while (<FILE>) {
 
87
                if (/\$Id: \S+ (\d+) /) {
 
88
                        $enrev = $1;
 
89
                        last;
 
90
                }
 
91
                # Also support CVS style revision comments (depreciated)
 
92
                if (/\$Revision: (\d+) \$/) {
 
93
                        $enrev = $1;
 
94
                        last;
 
95
                }
 
96
        }
 
97
        close FILE;
 
98
        warn "failed to find revision for $plfname\n" unless $plrev;
 
99
        warn "failed to find revision for $enfname\n" unless $enrev;
 
100
        if ($notconverted) {
 
101
                warn "$plfname: contains revision comment for original document\n";
 
102
                warn "   use 'rev-update' to convert\n";
 
103
        }
 
104
        return ($plrev, $enrev, $untrans);
 
105
}
 
106
 
 
107
sub process
 
108
{
 
109
        my $enfname = $File::Find::name;
 
110
        return unless $enfname =~ m/\.xml$/;
 
111
        my $plfname = $enfname;
 
112
        $plfname =~ s,^en/,$lang/,;
 
113
        checkdiff($plfname, $enfname);
 
114
}
 
115
File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en');
 
116
#checkdiff("build/install.$lang.xml", "build/install.en.xml");
 
117
#checkdiff("release-notes.$lang.sgml","release-notes.sgml");
 
118
#checkdiff("index.$lang.html.m4","index.en.html.m4");
 
119
#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");