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

HTTP Error 429: Too Many Requests / list index out of range #15

Closed
Nico-VC opened this issue Feb 18, 2024 · 2 comments
Closed

HTTP Error 429: Too Many Requests / list index out of range #15

Nico-VC opened this issue Feb 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Nico-VC
Copy link

Nico-VC commented Feb 18, 2024

Environment information

  • SO: win
  • python version: v3.11

Describe the bug
'Getting HTTP Error 429: Too Many Requests' exception when attempting to use MultiDictionary.translate().

I also get 'Error: list index out of range' instead of HTTP error at times. Can't reproduce one error consistently.

Returning either

UserWarning: range cannot be translated to ru-language as Google API is not available. Error: HTTP Error 429: Too Many Requests
  warn(f'{word} cannot be translated to {to}-language as Google API is not available. Error: {e}')

or

UserWarning: range cannot be translated to ru-language as Google API is not available. Error: list index out of range
  warn(f'{word} cannot be translated to {to}-language as Google API is not available. Error: {e}')

when passing testing the word 'Range' from the doc example.

To Reproduce
Encountering the issue with the following

from PyMultiDictionary import MultiDictionary

dictionary = MultiDictionary()
print(dictionary.translate('en', 'Range', to='ru'))

Instead of the specific translation for that language, a get a list of all the language translations.

Thanks! Trying to use this package for the first time.

@Nico-VC Nico-VC added the bug Something isn't working label Feb 18, 2024
@Nico-VC Nico-VC changed the title HTTP Error 429: Too Many Requests HTTP Error 429: Too Many Requests / Indexerror: list index out of range Feb 18, 2024
@Nico-VC Nico-VC changed the title HTTP Error 429: Too Many Requests / Indexerror: list index out of range HTTP Error 429: Too Many Requests / list index out of range Feb 18, 2024
@ppizarror
Copy link
Owner

ppizarror commented Feb 20, 2024

Hi @Nico-VC. Sadly, for that, you need a Google Cloud API key. Otherwise, error 429 appears as this API limits the number of requests; see yeahwhat-mc/goslate#2.
There is no other alternative (if you plan to use Google); you cannot bypass this limitation. One alternative is to use

from PyMultiDictionary import MultiDictionary

dictionary = MultiDictionary()
print(dictionary.translate('en', 'Range'))

@Nico-VC
Copy link
Author

Nico-VC commented Feb 22, 2024

I understand now! Thank you.

@Nico-VC Nico-VC closed this as completed Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants