ppizarror/PyMultiDictionary

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

Nico-VC opened this issue · 2 comments

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.

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'))

I understand now! Thank you.