Ask an expert: get a personalized answer within 24 hrs!X Close

Pocket Translator

Pocket Translator

$4.02

(5 stars)

(110)


Download for Android

10 - 50 downloads

Add this app to your lists
View bigger - Pocket Translator for Android screenshot
View bigger - Pocket Translator for Android screenshot
View bigger - Pocket Translator for Android screenshot
View bigger - Pocket Translator for Android screenshot
Translate English into Any and Every Language. Speak it or Type it!!!

Translate from English to any language, supports all alphabetical languages (50+).

Ideal for traveling, taking taxi, finding restaurants, getting around anywhere from Europe to Russia to Iceland to Africa to Anywhere!!!!

-----------------------------------------------------------
I'm inspired to create technologies that help people, and like always here is the code, originally written in Python, for anyone so inclined to play around with it and make it better:)
-----------------------------------------------------------
import httplib, mimetypes, mimetools, urllib2, android, sys, time, os, re
from urllib import urlretrieve
from urlparse import urljoin
import os.path
import urllib
import urlparse
import gzip as gzip_
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
try:
import simplejson as json
except ImportError:
import json

API_URL = 'http://SomeTranslationAPI eg: translate.foofleapis.com/translate_a/t'
DEFAULT_USER_AGENT = ('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 '
'(KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6')

def translate(text, target_language='en', source_language=None, html=True,
user_agent=DEFAULT_USER_AGENT, referer=None, origin=None,
timeout=None, flat=False, urlopen=urllib2.urlopen, gzip=True):
if isinstance(text, basestring):
text = (text,)
headers = {
'User-Agent': user_agent,
'Accept-Charset': 'utf-8',
}
if gzip:
headers['Accept-Encoding'] = 'gzip'
if referer:
headers['Referer'] = referer
headers['Origin'] = '%s://%s/' % urlparse.urlsplit(referer)[:2]
if origin and origin != headers['Origin']:
raise ValueError('Origin and referer not matched', origin,
headers['Origin'])
elif origin:
headers['Origin'] = origin
qs = (
('client', 'te_lib'),
('format', html and 'html' or ''),
('v', '1.0'),
('logld', 'v10'),
)
data = []
for block in text:
if isinstance(block, unicode):
block = block.encode('utf8')
else:
try:
block.decode('utf8')
except UnicodeDecodeError:
raise ValueError('Text must be utf8 or unicode')
data.append(('q', block))
data += [
('sl', source_language or ''),
('tl', target_language),
('tc', '1'),
]
req = urllib2.Request(API_URL + '?' + urllib.urlencode(qs),
urllib.urlencode(data), headers=headers)
resp = urlopen(req, **(timeout and {'timeout': timeout} or {}))
if gzip:
resp_cont = gzip_.GzipFile(fileobj=StringIO(resp.read()), mode='r').read()
else:
resp_cont = resp.read()
result = json.loads(resp_cont.decode('string-escape'),strict=False)
if not source_language:
result, source_language = result[:-1], result[-1]
elif len(text) == 1:
result = (result,)
if flat:
return u' '.join(result)
return result

droid=android.Android()
languageCode=droid.dialogGetInput('Input','Language Code').result
message=droid.dialogGetInput('Message','Type or push Microphone button to speak').result
droid.dialogCreateSpinnerProgress('Translating', 'Please Wait')
droid.dialogShow()
droid.setMediaVolume(5)
droid.generateDtmfTones('434753467674',1)
translated=translate(message,languageCode)
def ExtractAlphaNumeric(InputString):
from string import ascii_letters,digits
return "".join([ch for ch in InputString if ch in(ascii_letters+digits+' '+'.'+','+'\n'+'!'+'?'+'@'+'$'+'%'+'&'+';')])
translated=ExtractAlphaNumeric(translated[0])
webtxt=open('/sdcard/webtxt.txt','wb')
webtxt.write(translated)
webtxt.close()
droid.dialogDismiss()
droid.webViewShow('file:///sdcard/webtxt.txt')

Tags: pocket translator, pocket translator test.

Recently changed in this version

More Languages supported!


Comments and ratings for Pocket Translator

  • There aren't any comments yet, be the first to comment!