Google Translate API for Sanskrit

Viewed 170
2 Answers

Translate API and Google Translate are two different products. Sanskrit is not yet released on Translate API.

As a workaround, you may use this API that uses Google Translate as its back-end.

Sample script:

import translators as ts

text='hi'

print(ts.google(query_text=text,to_language='sa'))

Output: enter image description here

Disclaimer: The suggested workaround API is subject to limitation as per this support thread.

You can do it as follows:

import googletrans
from googletrans import Translator

translator = Translator(service_urls=['translate.googleapis.co.in'])
translated = translator.translate("",src='auto', dest='en')

print(translated.text)

service_urls allows to use the specific region-google translate. We need to keep src(source) language to auto because if we put "sa"(which is for Sanskirt), It will give an error. Therefore, it is better for it to choose the language itself as "sa".

Related