MetaTrans::BaseMetaTrans::Base is an abstract base class for creating meta-translator plug-ins. | |
Download |
MetaTrans::Base Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Jan Pomikalek
- Publisher web site:
- http://search.cpan.org/~janpom/MetaTrans-1.04/lib/MetaTrans/Base.pm
MetaTrans::Base Tags
MetaTrans::Base Description
MetaTrans::Base is an abstract base class for creating meta-translator plug-ins. MetaTrans::Base is an abstract base class for creating meta-translator plug-ins.SYNOPSIS # This is not a working example. It serves for illustration only. # For a working one see MetaTrans::UltralinguaNet source code. package MetaTrans::MyPlugin; use MetaTrans::Base; use vars qw(@ISA); @ISA = qw(MetaTrans::Base); use HTTP::Request; use URI::Escape; sub new { my $class = shift; my %options = @_; $options{host_server} = "www.some-online-translator.com" unless (defined $options{host_server}); my $self = new MetaTrans::Base(%options); $self = bless $self, $class; # supported translation directions: # English German # English French # English Spanish $self->set_languages('eng', 'ger', 'fre', 'spa'); $self->set_dir_1_to_all('eng'); $self->set_dir_all_to_1('eng'); return $self; } sub create_request { my $self = shift; my $expression = shift; my $src_lang_code = shift; my $dest_lang_code = shift; # our-language-codes-to-server-language-codes conversion table my %table = (eng => 'eng', ger => 'deu', fre => 'fra', spa => 'esp'); return new HTTP::Request('GET', 'http://www.some-online-translator.com/translate.cgi?' . 'expr=' . uri_escape($expression) . '&' . 'src=' . $table{$src_lang_code} . '&' . 'dst=' . $table{$dest_lang_code} ); } sub process_response { my $self = shift; my $contents = shift; # we don't care about these here, but # in some cases we might need to care my $src_lang_code = shift; my $dest_lang_code = shift; my @result; while ($contents =~ m| ([^
MetaTrans::Base Related Software