mouuff / mtranslate

A simple api for google translate
MIT License
286 stars 83 forks source link

can't insert inside of facebook chatbots #13

Closed omarhassanatef closed 7 years ago

omarhassanatef commented 7 years ago

from mtranslate import translate x = message_text def main(): to_translate = x x1 =(translate(to_translate)) x2 =(translate(to_translate, 'ar'))

x = x1 + "     " + x2

if name == 'main': main()

mouuff commented 7 years ago

If you are using windows:

you can try to run this command (in the cmd) before launching the script: chcp 1256 It will change windows page code for arab

you can get rid of the error (but it will not fix everything) : x1.encode(sys.stdout.encoding, errors='replace')

I also heard about a module called "win-unicode-console" for windows (install with pip) but I did not try it

omarhassanatef commented 7 years ago

i am using python 3.4

its working on windows , but when i try to insert it in my facebook messenger chatbot online , nothing happens

can you help?

mouuff commented 7 years ago

I can't help without informations, (like errors code, sample code to highlight the problem)

mouuff commented 7 years ago

could you paste your code on gist.github.com or pastebin.com ?

omarhassanatef commented 7 years ago

this is my full chatbot code , its supposed to receive the user messsage ( text_message ) and then using your mtranslate , translates it and re-set the value of text_message to the new translation and then re send it to the user

but it just stops responding can you see something wrong ?

mouuff commented 7 years ago

I can't use your code if you don't paste it in a proper way github comments syntax breaks it

omarhassanatef commented 7 years ago

https://github.com/omarhassanatef/chatbot

sorry im new to github :D , here it is

mouuff commented 7 years ago

It is not working because message_text is not defined

mouuff commented 7 years ago

Update?

omarhassanatef commented 7 years ago

the issue was with that the text was ascii code , it needs to be UTF-8 , it works perfectly