source: git/lib/checkshortcut.pl @ d4d6909

add-show-splaysline_contentsproj-api-updatestereosvn/github/mastersvn/origin/mastersvn/tags/1.2.3svn/tags/1.2.4svn/tags/1.2.5svn/trunk
Last change on this file since d4d6909 was d86459c, checked in by Olly Betts <olly@…>, 11 years ago

lib/,src/mainfrm.cc,src/mainfrm.h: We now use .po and .pot files as
the master format for storing translations in (rather than
messages.txt), and then translate these into Survex's .msg format.

git-svn-id: file:///home/survex-svn/survex/trunk@3595 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/usr/bin/perl -w
2require 5.008;
3use bytes;
4use strict;
5
6my %menu = ();
7my $srcdir = $ENV{'srcdir'} || '';
8$srcdir .= '/' if $srcdir;
9
10open I, "<$srcdir../src/mainfrm.cc" or die $!;
11while (<I>) {
12    m!(\w+)->Append[A-Za-z]*\(.*\(/\*.*?\*/(\d+)! && push @{$menu{$1}}, $2;
13}
14close I;
15
16#for (sort keys %menu) { print "$_:".join("|", @{$menu{$_}})."\n" }
17
18my $exitcode = 0;
19for my $lang (@ARGV) {
20    $lang =~ s/\.msg$//; # allow en or en.msg
21    my $hdr = "Lang $lang:\n";
22    # .msg files could be in srcdir or build directory when building outside
23    # the source tree
24    open L, "<$srcdir$lang.msg" or open L, "<$lang.msg" or die $!;
25    my $buf;
26    read L, $buf, 20;
27    read L, $buf, 999999;
28    close L;
29    my @msg = split /\0/, $buf;
30    for my $menu (sort keys %menu) {
31        my %sc = ();
32        my $bad = 0;
33        for (@{$menu{$menu}}) {
34            my ($acc) = ($msg[$_] =~ /\&(.)/);
35            if (!defined $acc) {
36                print "Lang $lang : message $_ '$msg[$_]' has no shortcut\n";
37            } else {
38                $acc = lc $acc;
39                if (exists $sc{$acc}) {
40                    if (defined $hdr) {
41                        print $hdr;
42                        $hdr = undef;
43                    }
44                    print "Menu $menu : '$msg[$sc{$acc}]' and '$msg[$_]' both use shortcut '$acc'\n";
45                    $bad = 1;
46                } else {
47                    $sc{$acc} = $_;
48                }
49            }
50        }
51        if ($bad) {
52            print "Unused letters: ", grep {!exists $sc{$_}} ('a' .. 'z'), "\n";
53            $exitcode = 1;
54        }
55    }
56    print "\n" unless defined $hdr;
57}
58exit $exitcode;
Note: See TracBrowser for help on using the repository browser.