You're viewing a comment by Sara and its responses.

Sara Permalink
April 21, 2013, 10:02

I used the translate code to convert word from Arabic to English, but gave me this error

Traceback (most recent call last):
File "C:\Python27\TR_TR.py", line 9, in

<module>

print translate(u"كتب", lang_to="en")
File "C:\Python27\xgoogle\translate.py", line 39, in translate
message = quote_plus(message)
File "C:\Python27\lib\urllib.py", line 1275, in quote_plus
return quote(s, safe)
File "C:\Python27\lib\urllib.py", line 1268, in quote
return ''.join(map(quoter, s))
KeyError: u'\u0643'
------------------------------------------------------------
and This is my code :
# -*- coding: cp1256 -*-
import sys
import HTMLParser
from xgoogle.translate import Translator

translate = Translator().translate

print translate(u"كتب", lang_to="en", lang_from='ar').encode('utf-8')

---------------------------------------------

Is the code does not use the Arabic language ??

Thanks..

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.