docs
[mirrors/Programs.git] / perl / translate.pl
CommitLineData
21c4e167
H
1#!/usr/bin/env perl
2
3#'http://translate.google.com/translate_t?text=hello&file=&sl=auto&tl=cs'
4#<div id=result_box dir="ltr">ahoj</div>
5
6
7package Google;
8use strict;
9use warnings;
10
11 use LWP;
12 use HTML::Entities;
13
14 my $url;
15 my $browser;
16 my $lang = 'cs';
17 #$lang = system('echo $LANG | cut -d _ -f 1');
18
19 sub translate {
20 my ($tl, $text) = @_;
21 $browser = LWP::UserAgent->new();
22 $browser->cookie_jar( {} );
23 $browser->agent("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)");
24 my $response = $browser->get( 'http://translate.google.com/translate_t',
25 [ 'sl' => 'auto',
26 'tl' => "$tl",
27 'text' => "$text",
28 ]
29 );
30 #return decode_entities($response->content);
31 return $response->content;
32 #return $response->is_success;
33 }
34
35 print translate($lang, "Exploding iPhones may be a thing of the past. Researchers at Taiwan's Industrial Technology Research Institute have developed a new polymer, STOBA (that's self-terminated oligomers with hyper-branched architecture to you and me), that is added to the cathode material inside a lithium-ion battery to keep them from overheating. 'Fires or explosions in these batteries are caused by short circuits,' said Wu Hung-chun, a researcher at ITRI, explaining that even minor mishandling such as dropping the handset could result in damage causing a short circuit. 'The technology is ready for lithium-ion batteries used in electronic devices, mobile phones, laptops,' said Wu. And ITRI has started testing STOBA on electric car batteries.");
This page took 0.199568 seconds and 4 git commands to generate.