File: check_translation

package info (click to toggle)
language-env 0.64
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,588 kB
  • ctags: 125
  • sloc: perl: 6,243; makefile: 83; tcl: 64; sh: 18
file content (120 lines) | stat: -rwxr-xr-x 2,859 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
#
#
# Utility to check strings which need translation.
#
# Note that Cyrillic languages (be, bg, mk, sr, and uk) are not checked.
#
#

print <<EOF;
---------------------------------------------
Now checking translation for each language
EOF

#--------------------------------
# check strings in 'set-language-env'
#--------------------------------
sub printf_ ($@) {
	$msgid{$_[0]} = "set-language-env: $num";
}

open(FILE, "./set-language-env") || die "CANNOT OPEN set-language-env.\n";
$num = 0;
while($line=<FILE>) {
	$num++;
	if ($line !~ /&printf_/) {next;}
	
	$a = $line;
	if ($line !~ /\);\s$/) {
		while ($line = <FILE>) {
			$num++;
			$a .= $line;
			if ($line =~ /\);\s$/) {last;}
		}
	}
	eval($a);
	if ($@) {printf STDERR "$a\n...\n$@";}
}
close(FILE);

#---------------------------------------
# build a list of all support.*.pl files
#---------------------------------------
opendir(DIR, ".") || die "Cannot open this directory.\n";
@filelist1 = readdir(DIR);
closedir(DIR);
@filelist = sort(@filelist1);
foreach $filename (@filelist) {
	if ($filename !~ /^support\.(.*)\.pl.*$/) {next;}
	push(@supports,$filename);
}

#-----------------------------
# check all support.*.pl files
#-----------------------------
foreach $s (@supports) {
	%messages = undef;
	open(FILE, $s) || die "CANNOT OPEN $s\n";
	@file1 = <FILE>; close(FILE); $file = join("", @file1);
	eval($file);

	print "Checking $s ...";

	if ($file1[0] =~ /!([^!]+)!/) {
		$langname = $1;
		if ($langname =~ /([\x80-\xff]+)/) {
			print "\n*** error ***: non-ASCII character for ".
			"language name \"$langname\" (bad character is ".
			"\"$1\"). in the first line\n";
			exit(1);
		}
	}

	foreach $m (keys %msgid) {
		if (exists $messages{$m}) {
			if ($messages{$m} =~ /([^\000]*)\000([^\000]*)/) {
				if ($1 =~ /([\x80-\xff]+)/) {
					print "\n*** error ***: non-ASCII".
					" character before \\000" .
					" in \"$messages{$m}\"\n".
					"bad character is \"$1\".\n";
					exit(1);
				}
			}
			next;
		}
		print "\n*** error ***: no translation for: $msgid{$m}\n";
		print "message = \"$m\"\n";
		exit(1);
	}
	print " done\n";
}

#------------------
# check other items
#------------------
open(FILE, "debian/docs") || die "CANNOT OPEN debian/docs\n";
@docs = <FILE>; close(FILE);
open(FILE, "set-language-env.1") || die "CANNOT OPEN set-language-env.1\n";
@manual = <FILE>; close(FILE);

foreach $s (@supports) {
	if ($s !~ /^support\.([^\.]+)\.pl$/) {next;}
	$lang = $1;

	if (grep(/README\.$lang/, @filelist)) {
		if (grep(/README\.$lang/, @docs) == 0) {
			print "*** error ***: README.$lang is not listed in" .
			" debian/docs.\n";
			exit(1);
		}
	} else {
		print "*** error ***: README.$lang is not supplied\n";
		exit(1);
	}
	if (grep(/\.B\s+$lang/, @manual) == 0) {
		print "*** error ***: $lang is not mentioned in manual.\n";
		exit(1);
	}
}