Skip to content

Instantly share code, notes, and snippets.

@otsune
Created October 21, 2010 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otsune/639320 to your computer and use it in GitHub Desktop.
Save otsune/639320 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use WebService::Simple;
use Encode;
my $text = join " ", @ARGV;
my $googletrans = WebService::Simple->new(
base_url => 'http://ajax.googleapis.com/ajax/services/',
response_parser => 'JSON',
params => {v => '1.0', langpair => 'ja|en'},
);
my $response = $googletrans->get(
'language/translate', { q => $text}
);
print encode_utf8($response->parse_response->{responseData}->{translatedText}), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment