Translate from English To Arabic

7 views (last 30 days)
hanan
hanan on 6 Jun 2011
Commented: Benjamin on 29 Mar 2025
I tried to translate text from English to Arabic using following code:
url = 'http://ajax.googleapis.com/ajax/services/language/translate';
page = urlread(url, 'get', {'v', '1.0','q', 'Hello', ... 'langpair', ['en' '|' 'ar']});
but the result will be
page =
{"responseData": {"translatedText":""}, "responseDetails": null, "responseStatus": 200}
Please help me to solve this problem.

Answers (1)

Benjamin
Benjamin on 25 Mar 2025
Edited: Walter Roberson on 28 Mar 2025
The issue is that Google's old Translation API (v1.0) is deprecated and no longer works. Instead, use the Google Cloud Translation API or an alternative like DeepL.
For Google Cloud Translation API, you can use this approach in Python:
python
from googletrans import Translator
translator = Translator()
translated_text = translator.translate("Hello", src="en", dest="ar")
print(translated_text.text)
If you need a MATLAB solution, consider calling an API using webread(), but you’ll need an Translation API key.
  2 Comments
Walter Roberson
Walter Roberson on 28 Mar 2025
Edited: Walter Roberson on 28 Mar 2025
[Spam link removed... again]
Benjamin
Benjamin on 29 Mar 2025
Ok link posting is spam. Sorry for this .

Sign in to comment.

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!