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

Missing 1 required positional argument: 'client' ERROR #392

Open
2 of 6 tasks
d4r14h opened this issue Jan 14, 2024 · 0 comments
Open
2 of 6 tasks

Missing 1 required positional argument: 'client' ERROR #392

d4r14h opened this issue Jan 14, 2024 · 0 comments

Comments

@d4r14h
Copy link

d4r14h commented Jan 14, 2024

Googletrans version:

  • 4.0.0rc1
  • 3.1.0a0
  • 3.0.0
  • 2.x

I'm submitting a ...

  • bug report
  • feature request

Current behavior:

When I run my code, it gives me an error

  File "/home/p4riah/Documents/Scripts/python/multiling.py", line 5, in <module>
    acquirer = TokenAcquirer()
TypeError: __init__() missing 1 required positional argument: 'client'

Expected behavior:
Translating text from english and bumping it through 100 random languages and back to english (for funny effect)

Steps to reproduce:

All I did was run the code given below

Related code:

from googletrans import Translator
from googletrans.gtoken import TokenAcquirer
import random

acquirer = TokenAcquirer()
text = 'test'
tk = acquirer.do(text)


langs = [
    'af', 'sq', 'am', 'ar', 'hy', 'az', 'eu', 'be', 'bn', 'bs', 'bg', 'ca', 'ceb', 
    'ny', 'zh-cn', 'zh-tw', 'co', 'hr', 'cs', 'da', 'nl', 'en', 'eo', 'et', 'tl',
    'fi', 'fr', 'fy', 'gl', 'ka', 'de', 'el', 'gu', 'ht', 'ha', 'haw', 'iw', 'he', 
    'hi', 'hmn', 'hu', 'is', 'ig', 'id', 'ga', 'it', 'ja', 'jw', 'kn', 'kk', 'km', 
    'ko', 'ku', 'ky', 'lo', 'la', 'lv', 'lt', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 
    'mi', 'mr', 'mn', 'my', 'ne', 'no', 'or', 'ps', 'fa', 'pl', 'pt', 'pa', 'ro', 
    'ru', 'sm', 'gd', 'sr', 'st', 'sn', 'sd', 'si', 'sk', 'sl', 'so', 'es', 'su', 
    'sw', 'sv', 'tg', 'ta', 'te', 'th', 'tr', 'uk', 'ur', 'ug', 'uz', 'vi', 'cy', 
    'xh', 'yi', 'yo', 'zu' ]

def translate_text(text, num_languages):
    translator = Translator()

    for _ in range(num_languages):
        translated_text = translator.translate(text, dest=str(random.choice(langs))).text
        text = translated_text

    back_to_english = translator.translate(text, dest='en').text
    return back_to_english

text_to_translate = "Hello, how are you?"
num_languages = 100
result = translate_text(text_to_translate, num_languages)

print("Original Text:", text_to_translate)
print("Translated and Back to English:", result)
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

1 participant