po/check_po.pl

Thu, 24 May 2018 14:13:35 -0500

author
Mike Ruprecht <cmaiku@gmail.com>
date
Thu, 24 May 2018 14:13:35 -0500
changeset 39064
d00b918ce190
parent 28507
f70cdbc9e491
permissions
-rwxr-xr-x

meson: Fix NLS by setting ENABLE_NLS in configuration

ENABLE_NLS was missing in the configuration header (config.h). This
caused none of our translations to be bound/looked for. This patch
adds that configuration setting back, fixing translations.

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

mercurial