mirror of
https://codeberg.org/scip/leo.git
synced 2025-12-16 20:21:03 +01:00
fix lang spec and parsing
This commit is contained in:
10
Changelog
10
Changelog
@@ -1,3 +1,13 @@
|
||||
1.41:
|
||||
|
||||
Generalized lang parsing and passing to dict.leo.org, which
|
||||
also adds support for new languages like ru, ch or pl. Thanks
|
||||
to J.A.Eichler.
|
||||
|
||||
1.40:
|
||||
|
||||
not logged, sorry.
|
||||
|
||||
1.39:
|
||||
|
||||
fixed rt.cpan.org#91464: disable caching if DB_File is not found.
|
||||
|
||||
85
Org.pm
85
Org.pm
@@ -7,7 +7,7 @@
|
||||
# or service marks of their respective holders.
|
||||
|
||||
package WWW::Dict::Leo::Org;
|
||||
$WWW::Dict::Leo::Org::VERSION = "1.40";
|
||||
$WWW::Dict::Leo::Org::VERSION = "1.41";
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -63,34 +63,31 @@ sub translate {
|
||||
my @match = ();
|
||||
|
||||
#
|
||||
# form var transitions for searchLoc
|
||||
#
|
||||
my %lang = (
|
||||
de2en => 1,
|
||||
en2de => -1,
|
||||
de2fr => 1,
|
||||
fr2de => -1,
|
||||
es2de => -1,
|
||||
de2es => 1,
|
||||
es => 0,
|
||||
en => 0,
|
||||
fr => 0,
|
||||
speak => "ende"
|
||||
);
|
||||
# form var transitions for searchLoc(=translation direction) and lp(=language)
|
||||
my %lang = ( speak => "ende" );
|
||||
|
||||
my @langs = qw(en es ru pt fr pl ch it);
|
||||
if ($this->{"-Language"}) {
|
||||
if ($this->{"-Language"} =~ /fr/) {
|
||||
# used for francaise translation
|
||||
$lang{speak} = "frde";
|
||||
# en | fr | ru2en | de2pl etc
|
||||
# de2, 2de, de are not part of lang spec
|
||||
if (! grep { $this->{"-Language"} =~ /$_/ } @langs) {
|
||||
croak "Unsupported language: " . $this->{"-Language"};
|
||||
}
|
||||
elsif ($this->{"-Language"} =~ /es/) {
|
||||
$lang{speak} = "esde";
|
||||
my $spec = $this->{"-Language"};
|
||||
my $l;
|
||||
if ($spec =~ /(..)2de/) {
|
||||
$l = $1;
|
||||
$this->{"-Language"} = -1;
|
||||
$lang{speak} = "${l}de";
|
||||
}
|
||||
if (exists $lang{$this->{"-Language"}}) {
|
||||
$this->{"-Language"} = $lang{$this->{"-Language"}};
|
||||
elsif ($spec =~ /de2(..)/) {
|
||||
$l = $1;
|
||||
$this->{"-Language"} = 1;
|
||||
$lang{speak} = "${l}de";
|
||||
}
|
||||
else {
|
||||
croak "Unsupported language: " . $this->{"-Language"};
|
||||
$lang{speak} = $this->{"-Language"} . 'de';
|
||||
$this->{"-Language"} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,35 +415,31 @@ Possible values: fuzzy, exact, relaxed.
|
||||
=item I<-Language>
|
||||
|
||||
Translation direction. Please note that dict.leo.org always translates
|
||||
either to or from german. The following values can be used:
|
||||
either to or from german.
|
||||
|
||||
=over
|
||||
The following languages are supported: english, polish, spanish, portugese
|
||||
russian and chinese.
|
||||
|
||||
=item de
|
||||
You can specify only the country code, or append B<de2> in order to
|
||||
force translation to german, or preprend B<de2> in order to translate
|
||||
to the other language.
|
||||
|
||||
Alias for B<de2en> - german to english.
|
||||
Valid examples:
|
||||
|
||||
=item fr
|
||||
ru to or from russian
|
||||
de2pl to polish
|
||||
es2de spanish to german
|
||||
|
||||
Alias for B<de2fr> - german to french.
|
||||
Valid country codes:
|
||||
|
||||
=item es
|
||||
en english
|
||||
es spanish
|
||||
ru russian
|
||||
pt portugese
|
||||
pl polish
|
||||
ch chinese
|
||||
|
||||
Alias for B<de2es> - german to espaniol.
|
||||
|
||||
=item en2de
|
||||
|
||||
english to german.
|
||||
|
||||
=item fr2de
|
||||
|
||||
french to german.
|
||||
|
||||
=item es2de
|
||||
|
||||
espaniol to german.
|
||||
|
||||
=back
|
||||
Default: B<en>.
|
||||
|
||||
=back
|
||||
|
||||
@@ -541,6 +534,6 @@ Please don't forget to add debugging output!
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.40
|
||||
1.41
|
||||
|
||||
=cut
|
||||
|
||||
55
leo
55
leo
@@ -8,8 +8,6 @@
|
||||
# the term to be translated. It will then return the results in
|
||||
# an unformatted form.
|
||||
#
|
||||
# $Id: leo,v 1.33 2008/04/22 22:23:39 scip Exp $
|
||||
#
|
||||
# Copyleft (l) 2000-2016 by Thomas v.D. <tlinden@cpan.org>. leo may be
|
||||
# used and distributed under the terms of the GNU General Public License.
|
||||
# All other brand and product names are trademarks, registered trademarks
|
||||
@@ -37,7 +35,7 @@ my $default_c = "\033[0m"; # reset default terminal color
|
||||
my $bold_c = "\033[0;34m"; # blue color
|
||||
my $copy_c = "\033[0;35m"; # copyright message color (green)
|
||||
|
||||
my $version = "1.39";
|
||||
my $version = "1.41";
|
||||
my $config = $ENV{HOME} . "/.leo";
|
||||
my $cache = $ENV{HOME} . "/.leo-CACHE.db";
|
||||
|
||||
@@ -137,7 +135,8 @@ if (-e $config) {
|
||||
foreach my $opt (keys %conf) {
|
||||
if (!exists $validopts{$opt}) {
|
||||
print "<$opt>\n";
|
||||
print STDERR "Error in config $config line: " . $line{$opt} . ". Unsupported option \"$opt\"!\n";
|
||||
print STDERR "Error in config $config line: " .
|
||||
$line{$opt} . ". Unsupported option \"$opt\"!\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -328,7 +327,7 @@ Translate a term from german to english or vice versa.
|
||||
-s, --spelltolerance=on|off allow spelling errors
|
||||
-m, --morphology=none|forcedAll provide morphology information
|
||||
-c, --chartolerance=fuzzy|exact allow umlaut alternatives
|
||||
-l, --language=en|fr|de2(en|fr)|(en|fr)2de translation direction
|
||||
-l, --language=[de2]<countrycode>[2de] translation direction
|
||||
-n, --noescapechars dont use escapes for highlighting
|
||||
-f, --force don't use the query cache
|
||||
-u, --user=username user for proxy authentication
|
||||
@@ -340,7 +339,24 @@ Translate a term from german to english or vice versa.
|
||||
<term> is the string you are asking to be translated. It will
|
||||
be requested from STDIN if not specified on the commandline.
|
||||
|
||||
Report bugs to <tom\@daemon.de>.
|
||||
Supported <countrycode>s are:
|
||||
|
||||
en english
|
||||
es spanish
|
||||
ru russian
|
||||
pt portugese
|
||||
pl polish
|
||||
ch chinese
|
||||
|
||||
You can specify only the country code, or append B<de2> in order to
|
||||
force translation to german, or preprend B<de2> in order to translate
|
||||
to the other language. Valid examples:
|
||||
|
||||
ru to or from russian
|
||||
de2pl to polish
|
||||
es2de spanish to german
|
||||
|
||||
Report bugs to <tlinden\@cpan.org>.
|
||||
);
|
||||
|
||||
exit 1;
|
||||
@@ -412,11 +428,30 @@ Default: B<relaxed>.
|
||||
|
||||
=item I<-l --language>
|
||||
|
||||
Translation direction.
|
||||
Translation direction. Please note that dict.leo.org always translates
|
||||
either to or from german.
|
||||
|
||||
Possible values: B<en>, B<fr>, B<de2en>, B<en2de>, B<de2fr> or B<fr2de>.
|
||||
The following languages are supported: english, polish, spanish, portugese
|
||||
russian and chinese.
|
||||
|
||||
B<en> and B<fr> do select the translation direction automatically.
|
||||
You can specify only the country code, or append B<de2> in order to
|
||||
force translation to german, or preprend B<de2> in order to translate
|
||||
to the other language.
|
||||
|
||||
Valid examples:
|
||||
|
||||
ru to or from russian
|
||||
de2pl to polish
|
||||
es2de spanish to german
|
||||
|
||||
Valid country codes:
|
||||
|
||||
en english
|
||||
es spanish
|
||||
ru russian
|
||||
pt portugese
|
||||
pl polish
|
||||
ch chinese
|
||||
|
||||
Default: B<en>.
|
||||
|
||||
@@ -632,6 +667,6 @@ browser, what is not prohibited. At least not today.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
This is the manpage for B<leo> version B<1.39>.
|
||||
This is the manpage for B<leo> version B<1.41>.
|
||||
|
||||
=cut
|
||||
|
||||
Reference in New Issue
Block a user