UlionTse / translators

🌏🌍🌎Translators🌎🌍🌏 is a library that aims to bring free, multiple, enjoyable translations to individuals and students in Python. Translators是一个旨在用Python为个人和学生带来免费、多样、愉快翻译的库。
https://pypi.org/project/translators/
GNU General Public License v3.0
1.62k stars 189 forks source link

[Bug]: KeyError: 'content' in iciba translator #125

Closed ali1hammoud closed 1 year ago

ali1hammoud commented 1 year ago

Debug Tips

What happened?

I wrote this code: ts.translate_text('hello, how are you?', translator='iciba', from_language='en', to_language='ar')

APP Version

5.7.1

Python Version

3.10

Runtime Environment

colab google

Country/Region

Russia

Relevant log output

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-16-abfc787020dd> in <cell line: 1>()
----> 1 ts.translate_text('hello, how are you?', translator='iciba', from_language='en', to_language='ar')

3 frames
/usr/local/lib/python3.10/dist-packages/translators/server.py in iciba_api(self, query_text, from_language, to_language, **kwargs)
   2310         time.sleep(sleep_seconds)
   2311         self.query_count += 1
-> 2312         return data if is_detail_result else data['content'] if data.get('isSensitive') == 1 else data['content']['out']
   2313 
   2314 

KeyError: 'content'

Code of Conduct

UlionTse commented 1 year ago

Hello fiend, What is your Runtime Environment?

translators_issues125
ali1hammoud commented 1 year ago

I updated the library to 5.7.6 Collecting translators Downloading translators-5.7.6-py3-none-any.whl (41 kB) and now it is working.

Thank you.