Translating Hinglish into English with Google Translate Api

10,076 views
Skip to first unread message

Billy Zhao

unread,
Sep 11, 2019, 5:44:35 PM9/11/19
to Google Cloud Translation API
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
Screenshot 2019-09-11 at 2.57.12 PM.png

Yingjie He

unread,
Sep 12, 2019, 8:22:40 PM9/12/19
to Google Cloud Translation API
Hi Billy,

Currently we don't support transliteration yet, Cloud Translation API is a little different from google translate apps and web apps, we will consider it as a feature request.

Thanks very much.

Trudeau Fernandes

unread,
Apr 20, 2020, 1:05:58 PM4/20/20
to Google Cloud Translation API
Is this support/feature for hinglish to english translation added or available now?



{
"q": "Tera naam kya hai",
"target": "en"
}

Returns me a response:
{
"data": {
"translations": [
{
"translatedText": "Tera naam kya hai",
"detectedSourceLanguage": "hi"
}
]
}
}

The source language is getting correctly detected... however its not getting translated to the desired target language.

I even tried giving the source as "hi", but it still does not do the translation.

However if the API is passed with the hindi script the translation works correctly:
{
"q":"तेरा नाम क्या है",
"target": "en"
}

Response we get is:
{
"data": {
"translations": [
{
"translatedText": "What is your name",
"detectedSourceLanguage": "hi"
}
]
}
}

Reply all
Reply to author
Forward
0 new messages