#!/usr/bin/perl -w use REST::Google::Translate; use CGI::Carp qw/fatalsToBrowser/; use CGI; use Encode; %languageHash = ( "zh" => "Chinese", "zh-CN" => "Chinese Simplified", "zh-TW" => "Chinese Traditional", "ja" => "Japanese", "hi" => "Hindi", "th" => "Thai", "vi" => "Vietnamese", "ru" => "Russian", "ar" => "Arabic", "af" => "Afrikaans", "ko" => "Korean" ); @languages = keys %languageHash; $textToTranslationize = CGI::param("textInput"); #$textToTranslationize = "this is a test of the translation service provided by a company"; # Do some fun language exchanging with a random language $randLang = $languages[rand($#languages+1)]; $convertedText = getTranslation($textToTranslationize, "en", $randLang); # Convert back to English and print HTML output print "Content-type: text/html\n\n"; print "