annotate po/check_po.pl @ 7806:c86f075b269a

[gaim-migrate @ 8453] I modified some of the libfaim connection stuff. I dunno, it seems cleaner this way. I like to be comfortable with what's going on. It's possible that FT and DC won't work now (although, they should), but I'll get to making them suck less pretty soon. Also upgraded the Doxyfile to 1 version newer. It mostly just moved some things around, but also removed the CGI_BLEH lines from the end. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 08 Dec 2003 05:41:04 +0000
parents 6173354a64dc
children 72f90ea7ae34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6238
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 #!/usr/bin/perl -w
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 # check_po.pl - check po file translations for likely errors
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 # Written by David W. Pfitzner dwp@mso.anu.edu.au
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 # This script is hereby placed in the Public Domain.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 # Various checks on po file translations:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 # - printf-style format strings;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 # - differences in trailing newlines;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 # - empty (non-fuzzy) msgid;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 # - likely whitespace errors on joining multi-line entries
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 # Ignores all fuzzy entries.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 # Options:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 # -x Don't do standard checks above (eg, just check one of below).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 # -n Check newlines within strings; ie, that have equal numbers
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 # of newlines in msgstr and msgid. (Optional because this may
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 # happen legitimately.)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 # -w Check leading whitespace. Sometimes whitespace is simply
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 # spacing (eg, for widget labels etc), or punctuation differences,
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 # so this may be ok.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 # -W Check trailing whitespace. See -w above.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 # -p Check trailing punctuation.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 # -c Check capitalization of first non-whitespace character
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 # (only if [a-zA-Z]).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 # -e Check on empty (c.q. new) msgstr
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 # Reads stdin (or filename args, via <>), writes any problems to stdout.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 # Modified by Davide Pagnin nightmare@freeciv.it to support plural forms
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 # Version: 0.41 (2002-06-06)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 use strict;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 use vars qw($opt_c $opt_n $opt_p $opt_w $opt_W $opt_x $opt_e);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 use Getopt::Std;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 getopts('cnpwWxe');
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 # Globals, for current po entry:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 # Note that msgid and msgstr have newlines represented by the
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 # two characters '\' and 'n' (and similarly for other escapes).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 my @amsgid; # lines exactly as in input
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 my @amsgstr;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 my $entryline; # lineno where entry starts
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 my $msgid; # lines joined by ""
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 my $msgstr;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 my $is_fuzzy;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 my $is_cformat;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 my $state; # From constant values below.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 my $did_print; # Whether we have printed this entry, to
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 # print only once for multiple problems.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 use constant S_LOOKING_START => 0; # looking for start of entry
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 use constant S_DOING_MSGID => 1; # doing msgid part
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 use constant S_DOING_MSGSTR => 2; # doing msgstr part
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 # Initialize or reinitalize globals to prepare for new entry:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 sub new_entry {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 @amsgid = ();
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 @amsgstr = ();
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 $msgid = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 $msgstr = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 $entryline = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 $is_fuzzy = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 $is_cformat = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 $did_print = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 $state = S_LOOKING_START;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 # Nicely print either a "msgid" or "msgstr" (name is one of these)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 # with given array of data.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 sub print_one {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 my $name = shift;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 print " $name \"", join("\"\n \"", @_), "\"\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 # Print a problem (args like print()), preceeded by entry unless
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 # we have already printed that: label, and msgid and msgstr.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 sub print_problem {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 unless ($did_print) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 print "ENTRY:", ($ARGV eq "-" ? "" : " ($ARGV, line $entryline)"), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 print_one("msgid", @amsgid);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 print_one("msgstr", @amsgstr);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 $did_print = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 print "*** ", @_;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 # Check final newline: probably, translations should end in a newline
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 # if and only if the original string does.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 # (See also check_trailing_whitespace and check_num_newlines below.)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 sub check_trailing_newlines {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 my ($ichar, $schar);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 $ichar = (length($msgid)>=2) ? substr($msgid, -2, 2) : "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 $schar = (length($msgstr)>=2) ? substr($msgstr, -2, 2) : "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 if ($ichar eq "\\n" && $schar ne "\\n") {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 print_problem "Missing trailing newline\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 if ($ichar ne "\\n" && $schar eq "\\n") {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 print_problem "Extra trailing newline\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 # Check leading whitespace. In general, any leading whitespace should
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 # be the same in msgstr and msgid -- but not always.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 sub check_leading_whitespace {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 unless ($opt_w) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 if ($msgid =~ m/^(\s+)/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 if ($msgstr =~ m/^(\s+)/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 $str = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 print_problem "Different leading whitespace\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 # Check trailing whitespace. In general, any trailing whitespace should
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 # be the same in msgstr and msgid -- but not always.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 sub check_trailing_whitespace {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 unless ($opt_W) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 if ($msgid =~ m/((?:\s|\\n)+)$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 if ($msgstr =~ m/((?:\s|\\n)+)$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 $str = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 print_problem "Different trailing whitespace\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 # Check equal numbers of newlines. In general ... etc.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 sub check_num_newlines {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 unless ($opt_n) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 my $num_i = ($msgid =~ m(\\n)g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 my $num_s = ($msgstr =~ m(\\n)g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 if ($num_i != $num_s) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 print_problem "Mismatch in newline count\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 # Check capitalization of first non-whitespace character (for [a-zA-Z]
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 # only). In general ... etc.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 sub check_leading_capitalization {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 unless ($opt_c) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 if ($msgid =~ m/^\s*([a-zA-Z])/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 if ($msgstr =~ m/^\s*([a-zA-Z])/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 if (defined($id) && defined($str)) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 if (($id =~ /^[a-z]$/ && $str =~ /^[A-Z]$/) ||
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 ($id =~ /^[A-Z]$/ && $str =~ /^[a-z]$/)) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 print_problem "Different leading capitalization\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 # Check trailing 'punctuation' characters (ignoring trailing whitespace).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 # In general .. etc.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 sub check_trailing_punctuation {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 unless ($opt_p) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 # Might want more characters:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 if ($msgid =~ m/([\\\.\/\,\!\?\"\'\:\;])+(?:\s|\\n)*$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 if ($msgstr =~ m/([\\\.\/\,\!\?\"\'\:\;])+(?:\s|\\n)*$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 $str = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 ##print "$id $str\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 print_problem "Different trailing punctuation\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 # Check that multiline strings have whitespace separation, since
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 # otherwise, eg:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 # msgstr "this is a multiline"
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 # "string"
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 # expands to:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 # "this is a multilinestring"
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 sub check_whitespace_joins {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 my $ok = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 my $i = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 foreach my $aref (\@amsgid, \@amsgstr) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 my $prev = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 LINE:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 foreach my $line (@$aref) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 if (defined($prev)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 && length($prev)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 && $prev !~ /\s$/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 && $prev !~ /\\n$/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 && $line !~ /^\s/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 && $line !~ /^\\n/)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 $ok = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 last LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 $prev = $line;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 if (!$ok) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 print_problem("Possible non-whitespace line-join problem in ",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 ($i==0 ? "msgid" : "msgstr"), " \n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 $i++;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 # Check printf-style format entries.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 # Non-trivial, because translation strings may use format specifiers
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 # out of order, or skip some specifiers etc. Also gettext marks
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 # anything with '%' as cformat, though not all are.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 sub check_cformat {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 unless ($is_cformat) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 my (@iform, @sform);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 @iform = ($msgid =~ m/\%[0-9\.\$]*[a-z]/g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 @sform = ($msgstr =~ m/\%[0-9\.\$]*[a-z]/g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 ##print join("::", @iform), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 ##print join("::", @sform), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 my $js; # index in sform
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 my $j; # index into iform
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 SFORM:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 for ($js=0; $js < @sform; $js++) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 my $sf = $sform[$js];
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 my $sf_orig = $sf;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 if ($sf =~ s/^\%([0-9]+)\$(.*[a-z])$/\%$2/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 $j = $1-1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 $j = $js;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 if ($j > $#iform) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 print_problem("Format number mismatch for $sf_orig [msgstr:",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 ($js+1), "]\n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 next SFORM;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 my $if = $iform[$j];
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 if ($sf ne $if) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 print_problem("Format mismatch: $sf_orig [msgstr:", ($js+1), "]",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 " vs $if [msgid:", ($j+1), "]\n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 # Run all individual checks on current entry, reporting any problems.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 sub check_entry {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 if ($is_fuzzy) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 return;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 $msgid = join("", @amsgid);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 $msgstr = join("", @amsgstr);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 unless ($opt_x) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 if (length($msgid)==0) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 print_problem "Zero length msgid\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 if (length($msgstr)==0) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 unless ($opt_e) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 print_problem "Untranslated msgid\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 check_cformat;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 check_whitespace_joins;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 check_num_newlines;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 check_leading_whitespace;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 check_trailing_newlines;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 check_trailing_whitespace;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 check_leading_capitalization;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 check_trailing_punctuation;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 new_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 LINE:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 while(<>) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 if ( m(^\s*$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 if ($state==S_DOING_MSGSTR) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 check_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 new_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 if ( m(^\#, fuzzy) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 $is_fuzzy = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 if ( m(^\#, .*c-format) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 # .* is because can have fuzzy, c-format
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 $is_cformat = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 if ( m(^\#) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 if ( m(^msgid \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 $entryline = $.;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 @amsgid = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 $state = S_DOING_MSGID;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 if ( m(^msgid_plural \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 $entryline = $.;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 @amsgid = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 $state = S_DOING_MSGID;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 if ( m(^msgstr \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 @amsgstr = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 $state = S_DOING_MSGSTR;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 if ( m(^msgstr\[[0-2]\] \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 @amsgstr = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 $state = S_DOING_MSGSTR;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 if ( m(^\"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 if ($state==S_DOING_MSGID) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 push @amsgid, $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 } elsif($state==S_DOING_MSGSTR) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 push @amsgstr, $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 die "Looking at string $_ in bad state $state,";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 die "Unexpected at $.: ", $_;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 }