aboutsummaryrefslogtreecommitdiffstats
path: root/check_desc_trans.pl
blob: 94d911cdb25461c7a460da41922ff085717cb32a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/perl -w

# Check translation status for mailing list descriptions. Since these files
# aren't WML files, the translation data is stored in a separate file in
# each directory, listing the names of the files and the corresponding
# English version.
#
# Since I couldn't figure out how to add this to the regular check_trans.pl
# script, this is a separate script.
#
# To use this script, create a file called translation-check in each
# directory under <language>/MailingLists/desc/. In it you list the name of
# the translated file and the version of the English original, separated by
# whitespace. Then run this script, and it will tell you about which files
# are missing, which files are outdated, and if there are files translating
# files that are no longer in the English directory.
#
# There are no command line parameters.

# Originally written 2002-10-05 by Peter Karlsson <peterk@debian.org>
# © Copyright 2002-2003 Software in the public interest, Inc.
# This program is released under the GNU General Public License, v2.

# $Id$

# Get configuration
if (exists $ENV{DWWW_LANG}) 
{
	$language = $ENV{DWWW_LANG};
} 
elsif (open CONF, "<language.conf")
{
	while (<CONF>)
	{
		next if /^#/;
		chomp;
		$language = $_, next unless defined $language;
	}
}

die "Language not defined in DWWW_LANG or language.conf\n"
	unless defined $language;

# Counter
$old = 0;
$uptodate = 0;
$unknown = 0;

# Start-up
$directory = 'MailingLists/desc';
&process($directory);

# Results
print $old, " need to be updated.\n" if $old;
print $uptodate, " are up to date.\n" if $uptodate;
print $unknown, " are orphaned.\n" if $unknown;

sub process
{
    my $curdir = shift;
    my $source = 'english/' . $curdir;
    my $destination = $language . '/' . $curdir;

    my %sourcefile;
    my @subdirs;

    print "Checking $curdir\n";

    # Read the Entries file for the source directory
    open CVS, $source . '/CVS/Entries'
        or die "Cannot read $source/CVS/Entries: $!\n";

    while (<CVS>)
    {
    	next if /README/;
		if (m[^/([^/]+)/([0-9\.]+)/])
        {
            $sourcefile{$1} = $2;
        }
		elsif (m[^D/([^/]+)/])
        {
            push @subdirs, $1;
        }
    }
    close CVS;

    # Read the translation-check file for the destination directory
    if (open CHECK, $destination . '/translation-check')
    {
        # Get data for the entries and compare
        while (<CHECK>)
        {
            if (/^([^\s]+)\s*([0-9\.]+)$/)
            {
            	print "Ghost entry $destination/$1\n"
            		unless -f "$destination/$1";
                if (defined $sourcefile{$1})
                {
                    my ($file, $oldrev, $newrev) = ($1, $2, $sourcefile{$1});
                    if ($oldrev ne $newrev)
                    {
                        $old ++;
                        print "Need to update $destination/$file from ",
                              $oldrev, " to ", $newrev, "\n";
                    }
                    else
                    {
                        $uptodate ++;
                    }
		            delete $sourcefile{$1};
                }
                else
                {
                    print "Unknown translated file: $destination/$1\n";
                    $unknown ++;
                }
            }
        }
        foreach $untranslated (keys %sourcefile)
        {
        	print "Untranslated file: $destination/$untranslated ",
        	      $sourcefile{$untranslated}, "\n";
        }
    }
    else
    {
        warn "Cannot read $destination/translation-check: $!\nDirectory skipped\n";
    }


    # Process subdirs
    foreach $subdir (@subdirs)
    {
        &process($curdir . '/' . $subdir);
    }
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy