annotate po/check_po.pl @ 30157:98de21a2aa9a

I found these by running "strings" on some MSN binary files. Doesn't seem like that could be considered copyright infringement. They're not used right now, but it seems like they could be useful in the future.
author Mark Doliner <mark@kingant.net>
date Thu, 03 Jun 2010 04:10:13 +0000
parents 2046abd60e0a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24829
a675137fc598 other small German translation update
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 22015
diff changeset
1 #!/usr/bin/env perl
6238
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
28218
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
35 # TODO: This script needs to be able to handle Farsi's %Id flag for
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
36 # number format specifiers. More information on how it works, see
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
37 # http://www.gnu.org/software/hello/manual/gettext/c_002dformat.html
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
38 # It's possible someone has already made this change... look around
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
39 # for an updated version of this script.
2046abd60e0a Add a note. This script shows a lot of false warnings for fa.po
Mark Doliner <mark@kingant.net>
parents: 28197
diff changeset
40
6238
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 use strict;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 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
43 use Getopt::Std;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 getopts('cnpwWxe');
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 # Globals, for current po entry:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 # Note that msgid and msgstr have newlines represented by the
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 # two characters '\' and 'n' (and similarly for other escapes).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 my @amsgid; # lines exactly as in input
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 my @amsgstr;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 my $entryline; # lineno where entry starts
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 my $msgid; # lines joined by ""
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 my $msgstr;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 my $is_fuzzy;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 my $is_cformat;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 my $state; # From constant values below.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 my $did_print; # Whether we have printed this entry, to
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 # print only once for multiple problems.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 use constant S_LOOKING_START => 0; # looking for start of entry
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 use constant S_DOING_MSGID => 1; # doing msgid part
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 use constant S_DOING_MSGSTR => 2; # doing msgstr part
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 # Initialize or reinitalize globals to prepare for new entry:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 sub new_entry {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 @amsgid = ();
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 @amsgstr = ();
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 $msgid = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 $msgstr = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 $entryline = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 $is_fuzzy = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 $is_cformat = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 $did_print = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 $state = S_LOOKING_START;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 }
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 # Nicely print either a "msgid" or "msgstr" (name is one of these)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 # with given array of data.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 sub print_one {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 my $name = shift;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 print " $name \"", join("\"\n \"", @_), "\"\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 # Print a problem (args like print()), preceeded by entry unless
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 # we have already printed that: label, and msgid and msgstr.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 sub print_problem {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 unless ($did_print) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 print "ENTRY:", ($ARGV eq "-" ? "" : " ($ARGV, line $entryline)"), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 print_one("msgid", @amsgid);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 print_one("msgstr", @amsgstr);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 $did_print = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 print "*** ", @_;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 # Check final newline: probably, translations should end in a newline
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 # if and only if the original string does.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 # (See also check_trailing_whitespace and check_num_newlines below.)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 sub check_trailing_newlines {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 my ($ichar, $schar);
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 $ichar = (length($msgid)>=2) ? substr($msgid, -2, 2) : "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 $schar = (length($msgstr)>=2) ? substr($msgstr, -2, 2) : "";
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 if ($ichar eq "\\n" && $schar ne "\\n") {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 print_problem "Missing trailing newline\n";
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 if ($ichar ne "\\n" && $schar eq "\\n") {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 print_problem "Extra trailing newline\n";
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
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 }
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 # Check leading whitespace. In general, any leading whitespace should
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 # be the same in msgstr and msgid -- but not always.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 sub check_leading_whitespace {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 unless ($opt_w) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 if ($msgid =~ m/^(\s+)/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 if ($msgstr =~ m/^(\s+)/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 $str = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 print_problem "Different leading whitespace\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 }
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 # Check trailing whitespace. In general, any trailing whitespace should
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 # be the same in msgstr and msgid -- but not always.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 sub check_trailing_whitespace {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 unless ($opt_W) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 my ($id, $str);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 if ($msgid =~ m/((?:\s|\\n)+)$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 if ($msgstr =~ m/((?:\s|\\n)+)$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 $str = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 print_problem "Different trailing whitespace\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 }
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
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 # Check equal numbers of newlines. In general ... etc.
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 sub check_num_newlines {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 unless ($opt_n) { return; }
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 my $num_i = ($msgid =~ m(\\n)g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 my $num_s = ($msgstr =~ m(\\n)g);
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 if ($num_i != $num_s) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 print_problem "Mismatch in newline count\n";
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
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 }
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 # Check capitalization of first non-whitespace character (for [a-zA-Z]
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 # only). In general ... etc.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 sub check_leading_capitalization {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 unless ($opt_c) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 my ($id, $str);
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 ($msgid =~ m/^\s*([a-zA-Z])/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 if ($msgstr =~ m/^\s*([a-zA-Z])/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 $str = $1;
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 if (defined($id) && defined($str)) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 if (($id =~ /^[a-z]$/ && $str =~ /^[A-Z]$/) ||
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 ($id =~ /^[A-Z]$/ && $str =~ /^[a-z]$/)) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 print_problem "Different leading capitalization\n";
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 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 }
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 # Check trailing 'punctuation' characters (ignoring trailing whitespace).
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 # In general .. etc.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 sub check_trailing_punctuation {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 unless ($opt_p) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 my ($id, $str);
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 # Might want more characters:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 if ($msgid =~ m/([\\\.\/\,\!\?\"\'\:\;])+(?:\s|\\n)*$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 $id = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 $id = "";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 if ($msgstr =~ m/([\\\.\/\,\!\?\"\'\:\;])+(?:\s|\\n)*$/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 $str = $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 $str = "";
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 ##print "$id $str\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 if ($id ne $str) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 print_problem "Different trailing punctuation\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 # Check that multiline strings have whitespace separation, since
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 # otherwise, eg:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 # msgstr "this is a multiline"
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 # "string"
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 # expands to:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 # "this is a multilinestring"
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 sub check_whitespace_joins {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 my $ok = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 my $i = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 foreach my $aref (\@amsgid, \@amsgstr) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 my $prev = undef;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 LINE:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 foreach my $line (@$aref) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 if (defined($prev)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 && length($prev)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 && $prev !~ /\s$/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 && $prev !~ /\\n$/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 && $line !~ /^\s/
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 && $line !~ /^\\n/)
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 $ok = 0;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 last LINE;
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 $prev = $line;
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 if (!$ok) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 print_problem("Possible non-whitespace line-join problem in ",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 ($i==0 ? "msgid" : "msgstr"), " \n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 $i++;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 }
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
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 # Check printf-style format entries.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 # Non-trivial, because translation strings may use format specifiers
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 # out of order, or skip some specifiers etc. Also gettext marks
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 # anything with '%' as cformat, though not all are.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 #
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 sub check_cformat {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 unless ($is_cformat) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 if ($opt_x) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 my (@iform, @sform);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 @iform = ($msgid =~ m/\%[0-9\.\$]*[a-z]/g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 @sform = ($msgstr =~ m/\%[0-9\.\$]*[a-z]/g);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 ##print join("::", @iform), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 ##print join("::", @sform), "\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 my $js; # index in sform
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 my $j; # index into iform
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 SFORM:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 for ($js=0; $js < @sform; $js++) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 my $sf = $sform[$js];
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 my $sf_orig = $sf;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 if ($sf =~ s/^\%([0-9]+)\$(.*[a-z])$/\%$2/) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 $j = $1-1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 $j = $js;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 if ($j > $#iform) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 print_problem("Format number mismatch for $sf_orig [msgstr:",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 ($js+1), "]\n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 next SFORM;
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 my $if = $iform[$j];
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 if ($sf ne $if) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 print_problem("Format mismatch: $sf_orig [msgstr:", ($js+1), "]",
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 " vs $if [msgid:", ($j+1), "]\n");
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 }
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
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 # Run all individual checks on current entry, reporting any problems.
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 sub check_entry {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 if ($is_fuzzy) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 return;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 $msgid = join("", @amsgid);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 $msgstr = join("", @amsgstr);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 unless ($opt_x) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 if (length($msgid)==0) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 print_problem "Zero length msgid\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 if (length($msgstr)==0) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 unless ($opt_e) { return; }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 print_problem "Untranslated msgid\n";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 check_cformat;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 check_whitespace_joins;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 check_num_newlines;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 check_leading_whitespace;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 check_trailing_newlines;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 check_trailing_whitespace;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 check_leading_capitalization;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 check_trailing_punctuation;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 new_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 LINE:
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 while(<>) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 if ( m(^\s*$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 if ($state==S_DOING_MSGSTR) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 check_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 new_entry;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 if ( m(^\#, fuzzy) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 $is_fuzzy = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 if ( m(^\#, .*c-format) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 # .* is because can have fuzzy, c-format
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 $is_cformat = 1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 if ( m(^\#) ) {
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 \"(.*)\"$) ) {
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(^msgid_plural \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 $entryline = $.;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 @amsgid = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 $state = S_DOING_MSGID;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 if ( m(^msgstr \"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 @amsgstr = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 $state = S_DOING_MSGSTR;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 }
28197
0d4b9ed6665a Some of our translations actually have 6 plural forms.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24829
diff changeset
370 if ( m(^msgstr\[[0-5]\] \"(.*)\"$) ) {
6238
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 @amsgstr = ($1);
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 $state = S_DOING_MSGSTR;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 if ( m(^\"(.*)\"$) ) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 if ($state==S_DOING_MSGID) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 push @amsgid, $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 } elsif($state==S_DOING_MSGSTR) {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 push @amsgstr, $1;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 } else {
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 die "Looking at string $_ in bad state $state,";
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 next LINE;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 }
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 die "Unexpected at $.: ", $_;
6173354a64dc [gaim-migrate @ 6731]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 }