Exemple #1
0
 def __get__(self, instance, owner):
     language = get_current_language()
     msg_id = instance.__dict__[self.name]
     if not msg_id:
         return u''
     if instance.id is None:
         return msg_id
     return MessageString.objects.lookup(msg_id, language)
Exemple #2
0
    def __set__(self, instance, value):
        lang_code = get_current_language()
        default_lang = get_default_language()

        if (lang_code == default_lang or not self.name in instance.__dict__ or
                instance.id is None):
            instance.__dict__[self.name] = value
        else:
            original = instance.__dict__[self.name]
            if original == u'':
                instance.__dict__[self.name] = value
                original = value

            message_string = MessageString.objects.get_msg_str(original,
                                                               lang_code)
            message_string.msg_str = value
            message_string.save()

        return None