#!/usr/bin/perl

=head1 Must differentiate specialpage(s) in all languages

Here we have a interesting accessibility problem that just leaps
out at you if you

=over

=item 1.

use a text browser or any non-CSS device -- and,

=item 2.

are a user of languages with a certain grammar mentioned below.

=back

=head2 The problem

In English the familiar sidebar of any Special Page has

 Views

   • Special page

 Toolbox

   • Special pages

 But imagine if it said instead

 Views

   • Special page

 Toolbox

   • Special page

You might say "Of course, one is in 'Views' and one in 'Toolbox'! I
don't see the problem." But try it out for a few years and you will
see it is a usability disaster, no matter how near or far they are to
each other there in the sidebar.

For many languages, using the same translation for 'specialpage' and
'specialpages' is quite logical, as in their grammar plurals are the
same as singulars -- in most situations, but not here, where extra
emphasis very much needs to made that 'specialpages' should be "All
special pages", "Special page groups"... however you might express it,
as long as it is different from the value of 'specialpage'.

=head2 The test program

Attached is a test program to find Messages*.php files with this
accessibility problem.

The output is batched into two groups, ranked by seriousness:

=over

=item 2.

Bug Cdo... These are the language files that need to be corrected.

=item 1.

Ace Av ... These are also in danger, as they only have one of
the strings, and could contribute to an identical pair somewhere else.
Indeed, even the "Qqq" file defines 'specialpages', but not
'specialpage'. The two must carry reminders that they must be
different in _all_ languages.

=back

To use this program, save this file to languages/messages/spfinder.txt and run

 $ perl spfinder.txt Messages*.php

=head2 Author

jidanni@jidanni.org 4/2009
=cut

use strict;
use warnings FATAL => q(all);
my ( %string, %group );
my $count = 0;
my %ll;
my $m;
my $debug = 1; #turn this off if you prefer
while (<>) {

    if (eof) {
        if ( ( scalar keys %string ) % 2 ) {
            $ARGV =~ /Messages(.*)\.php/;
            push @{ $group{$count} }, $1;
            if ($debug) { $ll{"$count $1"} = $m // ""; }
        }
        if ($debug) { undef $m; }
        undef %string;
        $count = 0;
    }
    next unless /^'specialpages?'/;
    my @F = split /\s*=>\s*/;
    if ($debug) { $m .= join "\t", @F; }
    $string{ $F[1] }++;
    $count++;
}
for ( reverse sort keys %group ) {
    print "$_: @{$group{$_}}\n";
}
if ($debug) {
    for ( reverse sort keys %ll ) { print "\n$_:\n$ll{$_}" }
}
