from django.db import models
from django.utils.translation import ugettext_lazy as _


class ActivityMixin(object):
    '''Mixin contains active field
    '''
    active = models.BooleanField(verbose_name=_('Is active'), default=True)


class HTMLMetaMixin(object):
    '''Mixin contains fields can be used to generate html meta tags and some
    other html > head tags

        title - <title> tag
        meta_description - <meta name="description" content="..." />
        meta_keywords - <meta name="keywords" content="..." />
    '''
    title = models.CharField(max_length=255, verbose_name=_('Title'),
                             blank=True, help_text=_('The title tag'))
    meta_description = models.TextField(verbose_name=_('Description'),
                             blank=True, help_text=_('Tag meta description'))
    meta_keywords = models.TextField(verbose_name=_('Keywords'), blank=True,
                                     help_text=_('Tag meta keywords'))


class Language(models.Model):
    '''Model represents language
    '''


class NavigationMixin(object):
    '''
    '''
    alias = models.SlugField(verbose_name=_('Alias'), unique=False,
                             help_text=_('URL string alias (slug)'))
    header = models.CharField(max_length=255, verbose_name=_('Header'),
                              blank=True, help_text=_('H1 page tag'))

@@ -58,16 +58,35 @@
 n import
+ get_language_info,
  ugettex
@@ -1066,332 +1066,2349 @@
 '''%0A
-%0A%0Aclass NavigationMixin(object):%0A    '''%0A    '''%0A    alias = models.SlugField(verbose_name=_('Alias'), unique=False,%0A                             help_text=_('URL string alias (slug)'))%0A    header = models.CharField(max_length=255, verbose_name=_('Header'),%0A                              blank=True, help_text=_('H1 page tag
+    code = models.CharField(_('Language code'), max_length=5, primary_key=True)%0A%0A    class Meta:%0A        verbose_name = _('language')%0A        verbose_name_plural = _('languages')%0A%0A    def __str__(self):%0A        '''Get language name for it's code%0A        '''%0A        return get_language_info(self.code)%5B'name'%5D%0A%0A    def __unicode__(self):%0A        '''Get language name for it's code%0A        '''%0A        return self.__str__()%0A%0A    def __repr__(self):%0A        '''Represent%0A        '''%0A        return ''.join(('%3C', self.__class__.__name__, ': %22', self.code, '%22%3E'))%0A%0A%0Aclass NavigationMixin(object):%0A    '''%0A    '''%0A    alias = models.SlugField(verbose_name=_('Alias'), unique=False,%0A                             help_text=_('URL string alias (slug)'))%0A    header = models.CharField(max_length=255, verbose_name=_('Header'),%0A                              blank=True, help_text=_('H1 page tag'))%0A%0A%0Aclass TranslatedMixin(object):%0A    '''Mixin adds method to select object translation for specified language%0A    from translations_set field (required to be set). Can be used to make%0A    objects translated to different languages.%0A%0A    As example for classes:%0A%0A        class Article(models.Model, TranslatedMixin):%0A            name = models.CharField(max_length=255)%0A%0A        class ArticleTranslation(TranslationMixin, models.Model):%0A            title = models.CharField(max_length=255)%0A            content = models.TextField()%0A            article = models.ForeignKey(Article,%0A                                        related_name='translations_set')%0A%0A    We can get translation:%0A%0A        article = Artcile.objects.get(name='Hello, world!')%0A        translation = article.get_translation('en')%0A        %0A    '''%0A    def get_translation(self, language):%0A        if isinstance(language, basestring):%0A            return self.translations_set.get(language_id=language)%0A        elif isinstance(language, Language):%0A            return self.translations_set.get(language=language)%0A        raise TypeError('%25s.get_translation() accepts only string or Language '%0A                        'argument but %25s given' %25 (self.__class__.__name__,%0A                                                   type(language)))%0A%0A%0Aclass TranslationMixin(object):%0A    '''Mixin contains field related to language.%0A    '''%0A    language = models.ForeignKey(Language, verbose_name=_('Language
 '))%0A

Add code for translations and languages with some documentation.