| 2 |
|
|
| 3 |
# This script checks if the translations of the documents are up to date. |
# 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 |
# When called with "-d" option, it also prints what has changed in the |
| 5 |
# original since last translation |
# 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 |
# When called with "-s" option, it also shows all files that are marked |
| 10 |
# untranslated |
# untranslated. |
| 11 |
|
|
| 12 |
# SYNOPSIS: |
# SYNOPSIS: |
| 13 |
# ./doc-check [-d] [-s] [-v] [-V] [lang] |
# ./doc-check [-d] [-r <revision>] [-s] [-v] [-V] [lang] |
| 14 |
# |
# |
| 15 |
# (uses $lang set below if lang is not given on commandline) |
# (uses $lang set below if lang is not given on commandline) |
| 16 |
|
|
| 17 |
use Getopt::Std; |
use Getopt::Std; |
| 18 |
use File::Find; |
use File::Find; |
| 19 |
$opt_d = $opt_s = $opt_v = $opt_V = 0; |
$opt_d = $opt_r = $opt_s = $opt_v = $opt_V = 0; |
| 20 |
getopts('dsvV'); |
getopts('r:dsvV'); |
| 21 |
# You may set this to your default language code |
# You may set this to your default language code |
| 22 |
$lang = shift || "pl"; |
$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 |
sub checkdiff |
| 29 |
{ |
{ |
| 31 |
my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname); |
my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname); |
| 32 |
$plrev and $enrev or return; |
$plrev and $enrev or return; |
| 33 |
if ( "$plrev" ne "$enrev" ) { |
if ( "$plrev" ne "$enrev" ) { |
| 34 |
|
if ($opt_d and $opt_r and $opt_r < $enrev) { |
| 35 |
|
$enrev = $opt_r; |
| 36 |
|
} |
| 37 |
if ($untrans) { |
if ($untrans) { |
| 38 |
print "$enfname : $plrev -> $enrev (untranslated)\n"; |
print "$enfname : $plrev -> $enrev (untranslated)\n"; |
| 39 |
} else { |
} else { |
| 112 |
$plfname =~ s,^en/,$lang/,; |
$plfname =~ s,^en/,$lang/,; |
| 113 |
checkdiff($plfname, $enfname); |
checkdiff($plfname, $enfname); |
| 114 |
} |
} |
| 115 |
|
|
| 116 |
|
sub process_obsolete |
| 117 |
|
{ |
| 118 |
|
my $plfname = $File::Find::name; |
| 119 |
|
return unless $plfname =~ m/\.xml$/; |
| 120 |
|
my $enfname = $plfname; |
| 121 |
|
$enfname =~ s,^$lang/,en/,; |
| 122 |
|
open FILE, $enfname or warn "$plfname: Probably obsoleted\n" and return; |
| 123 |
|
close FILE; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
warn "\nChecking for outdated or missing translations...\n" if $opt_v; |
| 127 |
File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en'); |
File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en'); |
| 128 |
|
warn "\nChecking for obsoleted translations...\n" if $opt_v; |
| 129 |
|
File::Find::find({ wanted => \&process_obsolete, no_chdir => 1 }, $lang); |
| 130 |
|
|
| 131 |
#checkdiff("build/install.$lang.xml", "build/install.en.xml"); |
#checkdiff("build/install.$lang.xml", "build/install.en.xml"); |
| 132 |
#checkdiff("release-notes.$lang.sgml","release-notes.sgml"); |
#checkdiff("release-notes.$lang.sgml","release-notes.sgml"); |
| 133 |
#checkdiff("index.$lang.html.m4","index.en.html.m4"); |
#checkdiff("index.$lang.html.m4","index.en.html.m4"); |
| 134 |
#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml"); |
#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml"); |
| 135 |
|
|
| 136 |
|
warn "All done.\n" if $opt_v; |