Hindi sentences on the online forums are nowadays more frequently written in Hinglish which takes the sound of Hindi and writing it in English Alphabet. With google translate apps and web apps, there is a neat feature where it automatically recognises Hinglish as Hindi and translates in English as seen in the screenshot attached.
The same behaviour is not replicated with Google Translate API when I try to translate Hinglish into English. How can I set up the api call in this case to replicate the behaviour that I get from the app or in the web browser?
#try out google translate api
# Imports the Google Cloud client library
from google.cloud import translate
# Instantiates a client
translate_client = translate.Client.from_service_account_json('/Users/billyzhaoyh/Downloads/SnehAItranslate-b7fa3e686978.json')
# The text to translate
text = u'Mujhe app bahat aachi lagteho mem or me aap ka me kuchh bhai karsakti hu dekta hu mujhe bahat achha lagata he'
# The target language
target = 'en'
# The source language
source = 'hi'
# Translates some text into Russian
translation = translate_client.translate(
text,
target_language=target,source_language=source)
print(u'Text: {}'.format(text))
print(u'Translation: {}'.format(translation['translatedText']))
the output is currently: Text: Mujhe app bahat aachi lagteho mem or me aap ka me kuchh bhai karsakti hu dekta hu mujhe bahat achha lagata he
Translation: Mujhe app bahat aachi lagteho mem or me aap ka me kuchh bhai karsakti hu dekta hu mujhe bahat achha lagata he