Reputation: 12260
So I was using google translate api npm @google-cloud/translate
with the following input:
translate.translate('Vijayashankara', {from: 'en', to: 'hi'})
Wanted to translate 'Vijayashankara' to 'Hindi'. I get the following response:
["Vijayashankara",{"data":{"translations":[{"translatedText":"Vijayashankara"}]}}]
Is there any way for me to get the response as विजयशंकर
, which is the hindi transliteration of 'Vijayashankara' ?
Upvotes: 1
Views: 889
Reputation: 27525
Looks like, name is 2 words.
After adding a space between words (that is, space before Capital letters), it works correctly:
Vijaya shankara
converts to विजया शंकरा
https://translate.google.com/#view=home&op=translate&sl=en&tl=hi&text=Vijaya%20shankara
Vijaya shankar
converts to विजया शंकर
https://translate.google.com/#view=home&op=translate&sl=en&tl=hi&text=Vijaya%20shankar
More details:
As names can be written without a space, may be, google should assume the space.
It does give Did you mean:
for both success & unsuccessful translation.
If unsuccessful, the source and target text will be same.
then we could use Did you mean:
however sometimes it is wrong:
VijayShankara
gives the Did you mean
as Vijay Shankar
, but should be Vijay Shankara
VijayaShankara
gives the Did you mean
as Vijay Shankar
, but should be Vijaya Shankara
Hope that helps.
Upvotes: 1
Reputation: 532
I tried translating 'Arpit' to Hindi using the same line that you used:
translate.translate('Arpit', 'hi')
and had the same response as you.
What I did to get 'अर्पित' was to specify the source language:
const options = {
from: "en",
to: "hi"
}
translate.translate("Arpit", options);
Upvotes: 0