Lingua-GA-Gramadoir
view release on metacpan or search on metacpan
scripts/gram-ga.pl view on Meta::CPAN
}
elsif ( $signal =~ m/^Option (.*) requires an argument/ ) {
$msg = gettext('option %s requires an argument', '`'.$1.'\'');
}
elsif ( $signal =~ m/^Option (.*) does not take/ ) {
$msg = gettext('option %s does not allow an argument', '`'.$1.'\'');
}
elsif ( $signal =~ m/^getopt/ ) {
$msg = gettext('error parsing command-line options');
}
elsif ( $signal =~ m/^Invalid attribute name ([^ ]*)/ ) {
$msg = gettext('Unable to set output color to %s', $1);
}
elsif ( $signal =~ m/^gram: maketext (.*)/ ) {
$msg = gettext('Language %s is not supported.', $1);
}
else {
die $signal;
}
my $dieclar = gettext('An Gramadoir'); # can't use global $clar yet
my $tryhelp = gettext('Try %s for more information.', '`gram-ga.pl --help\'');
print STDERR "$dieclar: $msg\n$tryhelp\n";
exit 1;
}
$lh = Lingua::GA::Gramadoir::Languages->get_handle();
$SIG{__DIE__} = 'localized_die';
# scalars for global options
use vars qw($api $aschur $aspell $comheadan $dath $help $html $iomlan $ionchod $aschod $litriu $version $xml $nounigram);
$dath = 'bold red';
$ionchod = 'ISO-8859-1';
$aschod = 'utf8';
eval {
local $SIG{__WARN__} = 'localized_die';
GetOptions (
'all|iomlan|a' => \$iomlan,
'api' => \$api,
'aspell|moltai' => \$aspell,
'list|litriu|l' => \$litriu,
'color|colour|dath=s' => \$dath,
'incode|ionchod|f=s' => \$ionchod,
'outcode|aschod|t=s' => \$aschod,
'no-unigram' => \$nounigram,
'help|cabhair|h' => \$help,
'html' => \$html,
'interface|comheadan=s' => \$comheadan,
'output|aschur|o=s' => \$aschur,
'version|leagan|v' => \$version,
'xml' => \$xml,
)
};
die "getopt error" if $@;
$xml = 1 if $nounigram;
unless ($dath eq "none") {
eval { color $dath };
}
if ($aschur) {
unless ($^O eq 'MSWin32') {
$aschur =~ s#^~(\w*)#$1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7] )#e;
}
open(OUTSTREAM, ">:encoding($aschod)", $aschur) or
warn "Can't open $aschur: $!\n";
}
else {
open(OUTSTREAM, ">&=STDOUT") or
warn "Couldn't alias STDOUT: $!\n";
binmode OUTSTREAM, ":encoding($aschod)"; # must be after alias
}
binmode STDERR, ":encoding($aschod)";
if ($comheadan) {
$lh = Lingua::GA::Gramadoir::Languages->get_handle($comheadan);
die "gram: maketext $comheadan" unless $lh;
}
# $lh->fail_with('failure_handler_auto');
# TRANSLATORS: Please leave untranslated, but add an acute accent to the
# "o" in "Gramadoir" if available in your character set and encoding.
# If you must translate, this is the Irish for (literally) "The Grammarian"
$clar = gettext('An Gramadoir');
if ($version) {
my $vstring = gettext('version %s', $VERSION);
my $copyright = 'Copyright (C) 2003-2007 Kevin P. Scannell';
my $gpl = gettext('This is free software; see the source for copying conditions. There is NO\\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\\nto the extent permitted by law.');
if ($html) {
$copyright =~ s#(Kevin P. Scannell)#<a href="http://borel.slu.edu/">$1</a><br><br>#;
print OUTSTREAM "<p>\n<a href=\"http://borel.slu.edu/gramadoir/\">$clar</a>, $vstring<br>\n$copyright\n<i>$gpl</i></p><hr>\n";
}
else {
print OUTSTREAM "$clar, $vstring\n$copyright\n$gpl\n";
}
close OUTSTREAM;
exit 0;
}
if ($help) {
my @helpmessages = (
gettext(
'Usage: %s [OPTIONS] [FILES]', "gram-ga.pl"),
"",
gettext(
"Options for end-users:"),
# TRANSLATORS: ~/.neamhshuim is an "ignore file" like those with spellcheckers
" -a, --all,",
gettext(
" --iomlan report all errors (i.e. do not use ~/.neamhshuim)"),
" -f, --incode,",
gettext(
" --ionchod=ENC specify the character encoding of the text to be checked"),
" -t, --outcode,",
gettext(
" --aschod=ENC specify the character encoding for output"),
" --interface,",
gettext(
" --comheadan=xx choose the language for error messages"),
" --color, --colour,",
gettext(
" --dath=COLOR specify the color to use for highlighting errors"),
( run in 1.632 second using v1.01-cache-2.11-cpan-6aa56a78535 )