wakaba / perl-webservice-microsoft-translator

Perl wrapper for Microsoft Translator API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NAME

WebService::Microsoft::Translator - Perl wrapper for Microsoft Translator API

SYNOPSIS

use WebService::Microsoft::Translator;
my $translator = WebService::Microsoft::Translator->new(
    app_id  => $app_id,
);
warn $translator->translate(
    from    => $from_lang,
    to      => $to_lang,
    text    => $text,
);

DESCRIPTION

The WebService::Microsoft::Translator module is a wrapper for Microsoft Translator API.

METHODS

$translator = WebService::Microsoft::Translator->new(%args)

Create a new instance of the translator interface. It returns the newly created object.

Following name-value pairs can be passed as options:

app_id => $app_id (REQUIRED)

Bing application ID used to access to the API.

onerror => $code

Error handler.

$onerror = $translator->onerror
$translator->onerror($onerror)

Get or set the error handler.

The error handler must be a code reference. The code will be invoked when some error is detected, with name-value pairs: message is a short text decribing the error; It might be a string returned by the API. type is an optional short string describing the kind of the error, if known. The error handler may throw an exception, if desired.

The default error handler warns the message.

$translated = $translator->translate(%args)

Translate a text using the API. The arguments must be given as name-value pairs.

text => text (REQUIRED)

The input text to translate. The value must be a (likely utf8-flagged) string.

from => langcode

The language of the input text, in Microsoft's language code. This option may be omitted for auto-detection.

to => langcode (REQUIRED)

The destination language, in Microsoft's language code.

The method returns the translated text, if available, or undef, otherwise. The text is utf8-flagged if necessary.

SEE ALSO

Microsoft Translator Developer & Web Master Support <http://social.msdn.microsoft.com/Forums/en-US/microsofttranslator/threads/>.

Microsoft Translator API - Frequently Asked Questions <http://social.msdn.microsoft.com/Forums/en-US/microsofttranslator/thread/c71aeddd-cc90-4228-93cc-51fb969fde09>.

Microsoft Translator <http://msdn.microsoft.com/en-us/library/dd576287.aspx>.

無償の Bing Translation APIを使用する(20110407), Takeshi Shinmura, <http://blogs.msdn.com/b/tashinmu/archive/2011/04/07/bing-translation-api-20110407.aspx>.

DEVELOPMENT

Latest version of the module is available from the GitHub repository: <https://github.com/wakaba/perl-webservice-microsoft-translator>.

Tests are automatically run at Travis CI: <http://travis-ci.org/wakaba/perl-webservice-microsoft-translator>.

Potentially outdated tarball distribution of the module might be available at: <http://wakaba.github.com/packages/perl/#WebService-Microsoft-Translator>.

AUTHOR

id:sano.

Wakaba <wakabatan@hatena.ne.jp>.

LICENSE

Copyright 2011-2012 Hatena <http://www.hatena.ne.jp/>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 99:

Non-ASCII character seen before =encoding in '無償の'. Assuming UTF-8

About

Perl wrapper for Microsoft Translator API