I can't believe I am getting this error again and again ....
Here is my class:
class LANGUAGE:
def __init__(self, val):
self.val = val
def Set(self):
return self.val
Here is the function call:
if text in translate._languages:
msg = "You have chosen the " + translate._languages[text]
global NewLang
newlang = LANGUAGE(text)
NewLang = newlang.Set()
blip.CreateChild().GetDocument().SetText(Trans.translate(msg, text,''))
elif CMD_HELP in text:
blip.CreateChild().GetDocument().SetText('''blabla bla ''')
elif CREDITS in text:
blip.CreateChild().GetDocument().SetText('''bla bla bla''')
else:
lng = Detect(message.encode('utf-8'))
newmsg = Trans.translate(message.encode('utf-8'), NewLang, '')
doc.AppendText( '\n\n['+translate._languages[NewLang] + '] ' + newmsg)
doc.AppendText( '\n\n[English] ' + Trans.translate(message.encode('utf-8'), 'en',''))
I am getting this error without using global NewLang
File "/base/data/home/apps/helloogoo/3.338280493491897811/helloogoo.py", line 83, in OnBlipSubmitted
newmsg = Trans.translate(message.encode('utf-8'), NewLang, '')
UnboundLocalError: local variable 'NewLang' referenced before assignment
And when I use global NewLang I get this error:
File "/base/data/home/apps/helloogoo/3.338280535936936291/helloogoo.py", line 83, in OnBlipSubmitted
newmsg = Trans.translate(message.encode('utf-8'), NewLang, '')
NameError: global name 'NewLang' is not defined
What should I do, it is killing me.