+ if (@ARGV) {
+ my $arg = shift @ARGV;
+ my $ok = 0;
+ foreach my $dir ("../locale/$arg", "locale/$arg", "../$arg", $arg) {
+ next unless -d $dir && -f "$dir/all" && -f "$dir/LANGUAGE";
+ $ok = chdir $dir;
+ last;
+ }
+
+ if (!$ok) {
+ print "The locale directory '$arg' could not be found.\n";
+ exit 1;
+ }
+
+ } elsif (!-f 'all' || !-f 'LANGUAGE') {
+ print "locales.pl was not called from a locale/* subdirectory,\n"
+ . "and no locale directory name was given.\n";
+ exit 1;
+ }