In 172 DEFAULT_LANGUAGE en In 173 class TranslatedUnicode unicode def

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
In [172]: DEFAULT_LANGUAGE='en'
In [173]: class TranslatedUnicode(unicode):
def __init__(self, string='', *args, **kwargs):
if 'trans' in kwargs:
if DEFAULT_LANGUAGE not in kwargs['trans']:
raise ValueError("Tried to initialize me without default lang (%s). got: %s" % (
DEFAULT_LANGUAGE, kwargs['trans']))
else:
self._trans = kwargs.pop('trans')
string = self._trans[DEFAULT_LANGUAGE]
super(TranslatedUnicode, self).__init__(string=string, *args, **kwargs)
.....:
In [183]: a = TranslatedUnicode('asd',trans={'en': 'qwe', 'ru': u'кве'})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/xa4a/merc/iasa/<ipython console> in <module>()
TypeError: 'trans' is an invalid keyword argument for this function