| 1 | package Bot::BasicBot::Pluggable::Module::Translate; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Bot::BasicBot::Pluggable::Module; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use base qw(Bot::BasicBot::Pluggable::Module); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use Locale::Language; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use Lingua::Translate; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | use Lingua::Translate::Babelfish; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | ▶ | sub said { | ||||||||||||||||||
|
Subroutine
said: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||
| 13 | 0 | my ($self, $mess, $pri) = @_; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 0 | my $sentence = $mess->{body}; | |||||||||||||||||||
| 16 | 0 | my $who = $mess->{who}; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 0 | ▶ | return unless ($pri == 2); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | my $to; | |||||||||||||||||||
| 21 | my $from; | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | return unless ($sentence =~ s!\s*translate to (\w+)(?: from (\w+))?\s*!$to = lc($1); $from = lc($2) || 'english'; ""!ei); | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
lc $2 || 'english'
MC/DC0%0/1
lc $2 || 'english'
lc $2
Truth table0%0/2
A
A= lc $2
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | ▶ | return "I need a sentence to translate!" if $sentence =~ m!^\s*$!; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | my $to_code = (length($to) == 2)? $to : lc(language2code($to)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 0 | ▶ | my $from_code = (length($from) == 2)? $from : lc(language2code($from)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | my $xl8r = Lingua::Translate->new(src => $from_code, dest => $to_code) || | ||||||||||||||||||
|
Condition0%0/2
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code) || (return "Can't do $from_code to $to_code")
MC/DC0%0/1
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code) || (return "Can't do $from_code to $to_code")
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code)
Truth table0%0/2
A
A= 'Lingua::Translate'->new('src', $from_code, 'dest', $to_code)
| |||||||||||||||||||||
| 32 | return "Can't do $from_code to $to_code"; | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | my $return = $xl8r->translate($sentence) || return "Hrmm, I couldn't translate '$sentence'"; | ||||||||||||||||||
|
Condition0%0/2
$xl8r->translate($sentence) || (return "Hrmm, I couldn't translate '${sentence}'")
MC/DC0%0/1
$xl8r->translate($sentence) || (return "Hrmm, I couldn't translate '${sentence}'")
$xl8r->translate($sentence)
Truth table0%0/2
A
A= $xl8r->translate($sentence)
| |||||||||||||||||||||
| 35 | 0 | return $return; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub help { | ||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 41 | 0 | return "translate to <language> [from <other language>] <phrase>"; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =head1 NAME | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Bot::BasicBot::Pluggable::Module::Translate - do language translations | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =head1 IRC USAGE | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | translate to <language> [from <other language>] <phrase> | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =head1 AUTHOR | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | Simon Wistow, <simon@thegestalt.org> | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head1 COPYRIGHT | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | Copyright 2005, Simon Wistow | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | Distributed under the same terms as Perl itself. | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =head1 SEE ALSO | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||
| 71 | |||||||||||||||||||||