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

IndexError while running the app using GOOGLE_TRANSLATE_KEY #33

Open
hackerkid opened this issue Jun 30, 2021 · 1 comment
Open

IndexError while running the app using GOOGLE_TRANSLATE_KEY #33

hackerkid opened this issue Jun 30, 2021 · 1 comment

Comments

@hackerkid
Copy link

hackerkid commented Jun 30, 2021

I am getting the following error while running translate_messages. I have generated a Google Translate API key and set it as GOOGLE_TRANSLATE_KEY as well.

masked@masked:~/masked$ ./manage.py translate_messages -l ar -u 
2021-06-30 08:43:14.585 INFO [autotranslate.management.commands.translate_messages] skipping translation for locale `vi`
2021-06-30 08:43:14.586 INFO [autotranslate.management.commands.translate_messages] filling up translations for locale `ar`
2021-06-30 08:43:14.683 INFO [googleapiclient.discovery_cache] file_cache is only supported with oauth2client<4.0.0
Traceback (most recent call last):
  File "./manage.py", line 157, in <module>
    execute_from_command_line(sys.argv)
  File "./manage.py", line 122, in execute_from_command_line
    utility.execute()
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 81, in handle
    self.translate_file(root, file, target_language)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 102, in translate_file
    self.update_translations(po, translated_strings)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 154, in update_translations
    translation = fix_translation(entry.msgid, translation)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 196, in fix_translation
    translation = restore_placeholders(msgid, translation)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 182, in restore_placeholders
    translation)
  File "/srv/masked-py3-venv/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 181, in <lambda>
    lambda matches: '{0}{1}{2}'.format(placehoders[0][0], placehoders[0][1], placehoders.pop(0)[2]),
IndexError: list index out of range
@Victhereum
Copy link

I am getting the following error while running translate_messages. I have generated a Google Translate API key and set it as GOOGLE_TRANSLATE_KEY as well.

masked@masked:~/masked$ ./manage.py translate_messages -l ar -u 
2021-06-30 08:43:14.585 INFO [autotranslate.management.commands.translate_messages] skipping translation for locale `vi`
2021-06-30 08:43:14.586 INFO [autotranslate.management.commands.translate_messages] filling up translations for locale `ar`
2021-06-30 08:43:14.683 INFO [googleapiclient.discovery_cache] file_cache is only supported with oauth2client<4.0.0
Traceback (most recent call last):
  File "./manage.py", line 157, in <module>
    execute_from_command_line(sys.argv)
  File "./manage.py", line 122, in execute_from_command_line
    utility.execute()
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 81, in handle
    self.translate_file(root, file, target_language)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 102, in translate_file
    self.update_translations(po, translated_strings)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 154, in update_translations
    translation = fix_translation(entry.msgid, translation)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 196, in fix_translation
    translation = restore_placeholders(msgid, translation)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 182, in restore_placeholders
    translation)
  File "/srv/masked-py3-venv/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/srv/masked-py3-venv/lib/python3.6/site-packages/autotranslate/management/commands/translate_messages.py", line 181, in <lambda>
    lambda matches: '{0}{1}{2}'.format(placehoders[0][0], placehoders[0][1], placehoders.pop(0)[2]),
IndexError: list index out of range

Where you able to solve it?

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

No branches or pull requests

2 participants