POE::Component::Lingua::Translate - A non-blocking wrapper around Lingua::Translate
use POE; use POE::Component::Lingua::Translate; POE::Session->create( package_states => [ main => [ qw(_start translated) ], ], ); $poe_kernel->run(); sub _start { my $heap = $_[HEAP]; $heap->{trans} = POE::Component::Lingua::Translate->new( alias => 'translator', back_end => 'Babelfish', src => 'en', dest => 'de', ); $poe_kernel->post(translator => translate => 'This is a sentence'); return; } sub translated { my $result = $_[ARG0]; # prints 'Dieses ist ein Satz' print $result . "\n"; }
POE::Component::Lingua::Translate is a POE component that provides a non-blocking wrapper around Lingua::Translate. It accepts translate events and emits translated events back.
translate
translated
new
Arguments
'alias', an optional alias for the component's session.
Any other arguments will be passed verbatim to Lingua::Translate's constructor.
session_id
Takes no arguments. Returns the POE Session ID of the component.
The POE events this component will accept.
The first argument should be a string containing some text to translate. The second argument (optional) can be a hash reference containing some context information. You'll get this hash reference back with the translated event.
shutdown
Takes no arguments, terminates the component.
The POE events emitted by this component.
ARG0 is the translated text. ARG1 is the context hashref from translate. If there was an error, ARG2 will be the error string.
Hinrik Örn Sigurðsson, hinrik.sig@gmail.com
Copyright 2008 Hinrik Örn Sigurðsson
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install POE::Component::Lingua::Translate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::Lingua::Translate
CPAN shell
perl -MCPAN -e shell install POE::Component::Lingua::Translate
For more information on module installation, please visit the detailed CPAN module installation guide.