Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: KeyError: 'data' in iflytek translator #126

Open
2 tasks done
ali1hammoud opened this issue May 13, 2023 · 2 comments
Open
2 tasks done

[Bug]: KeyError: 'data' in iflytek translator #126

ali1hammoud opened this issue May 13, 2023 · 2 comments
Assignees

Comments

@ali1hammoud
Copy link

ali1hammoud commented May 13, 2023

Debug Tips

  • I'm sure I've read this project's Issues of README.

What happened?

I wrote this code:
ts.translate_text('hello, how are you?', translator='iflytek', from_language='en', to_language='ar')
ts.translate_text('hello, how are you?', translator='niutrans', 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-17-bdc31f9ec4ac> in <cell line: 1>()
----> 1 ts.translate_text('hello, how are you?', translator='iflytek', from_language='en', to_language='ar')

3 frames
/usr/local/lib/python3.10/dist-packages/translators/server.py in iflytek_api(self, query_text, from_language, to_language, **kwargs)
   2488         time.sleep(sleep_seconds)
   2489         self.query_count += 1
-> 2490         return data if is_detail_result else eval(data['data'])['trans_result']['dst']
   2491 
   2492 

KeyError: 'data'
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
[<ipython-input-18-6bb03439ea15>](https://localhost:8080/#) in <cell line: 1>()
----> 1 ts.translate_text('hello, how are you?', translator='niutrans', from_language='en', to_language='ar')

3 frames
[/usr/local/lib/python3.10/dist-packages/translators/server.py](https://localhost:8080/#) in niutrans_api(self, query_text, from_language, to_language, **kwargs)
   3247             token_data = r_tk.json()
   3248 
-> 3249             self.account_info = {**guest_info, **token_data['data']}
   3250             self.api_headers = {**self.host_headers, **{'Jwt': self.account_info['token']}}
   3251             self.session.cookies.update({'Admin-Token': self.account_info['token']})

KeyError: 'data'

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ali1hammoud
Copy link
Author

ali1hammoud commented May 21, 2023

After updating to 5.7.6
I got these errors:

KeyError: 'data'

During handling of the above exception, another exception occurred:

TranslatorError                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/translators/server.py](https://localhost:8080/#) in _wrapper(*args, **kwargs)
    279                 raise_tips2_url = 'https://github.com/UlionTse/translators#supported-translation-services'
    280                 raise_tips2 = f'Please read for details: Status of Translator on this webpage({raise_tips2_url}).'
--> 281                 raise TranslatorError(f'{raise_tips1} {raise_tips2}')
    282         return _wrapper
    283 

TranslatorError: The function iflytek() has been not certified yet. Please read for details: Status of Translator on this webpage(https://github.com/UlionTse/translators#supported-translation-services).
KeyError: 'data'

During handling of the above exception, another exception occurred:

TranslatorError                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/translators/server.py](https://localhost:8080/#) in _wrapper(*args, **kwargs)
    279                 raise_tips2_url = 'https://github.com/UlionTse/translators#supported-translation-services'
    280                 raise_tips2 = f'Please read for details: Status of Translator on this webpage({raise_tips2_url}).'
--> 281                 raise TranslatorError(f'{raise_tips1} {raise_tips2}')
    282         return _wrapper
    283 

TranslatorError: The function niutrans() has been not certified yet. Please read for details: Status of Translator on this webpage(https://github.com/UlionTse/translators#supported-translation-services).

now it is clear that:
The function iflytek() has been not certified yet
The function niutrans() has been not certified yet

@UlionTse
Copy link
Owner

Hello friend!
Although these functions are implemented, they have not passed the test due to various reasons, and they are in an unavailable status. This status is also marked on the README page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants