Locatizations.
[wolnelektury.git] / src / social / models.py
index d46dc08..05cf722 100644 (file)
@@ -6,19 +6,18 @@ from django.db import models
 from django.conf import settings
 from django.core.exceptions import ValidationError
 from django.urls import reverse
-from django.utils.translation import gettext_lazy as _, get_language
 from catalogue.models import Book
 from wolnelektury.utils import cached_render, clear_cached_renders
 
 
 class BannerGroup(models.Model):
-    name = models.CharField(_('name'), max_length=255, unique=True)
-    created_at = models.DateTimeField(_('created at'), auto_now_add=True)
+    name = models.CharField('nazwa', max_length=255, unique=True)
+    created_at = models.DateTimeField('utworzona', auto_now_add=True)
 
     class Meta:
         ordering = ('name',)
-        verbose_name = _('banner group')
-        verbose_name_plural = _('banner groups')
+        verbose_name = 'grupa bannerów'
+        verbose_name_plural = 'grupy bannerów'
 
     def __str__(self):
         return self.name
@@ -36,41 +35,42 @@ class BannerGroup(models.Model):
 
 
 class Cite(models.Model):
-    book = models.ForeignKey(Book, models.CASCADE, verbose_name=_('book'), null=True, blank=True)
-    text = models.TextField(_('text'), blank=True)
-    small = models.BooleanField(_('small'), default=False, help_text=_('Make this cite display smaller.'))
-    vip = models.CharField(_('VIP'), max_length=128, null=True, blank=True)
-    link = models.URLField(_('link'))
-    video = models.URLField(_('video'), blank=True)
-    picture = models.ImageField(_('picture'), blank=True,
+    book = models.ForeignKey(Book, models.CASCADE, verbose_name='książka', null=True, blank=True)
+    text = models.TextField('tekst', blank=True)
+    small = models.BooleanField(
+        'mały', default=False, help_text='Sprawia, że cytat wyświetla się mniejszym fontem.')
+    vip = models.CharField('VIP', max_length=128, null=True, blank=True)
+    link = models.URLField('odnośnik')
+    video = models.URLField('wideo', blank=True)
+    picture = models.ImageField('ilustracja', blank=True,
             help_text='Najlepsze wymiary: 975 x 315 z tekstem, 487 x 315 bez tekstu.')
-    picture_alt = models.CharField(_('picture alternative text'), max_length=255, blank=True)
-    picture_title = models.CharField(_('picture title'), max_length=255, null=True, blank=True)
-    picture_author = models.CharField(_('picture author'), max_length=255, blank=True, null=True)
-    picture_link = models.URLField(_('picture link'), blank=True, null=True)
-    picture_license = models.CharField(_('picture license name'), max_length=255, blank=True, null=True)
-    picture_license_link = models.URLField(_('picture license link'), blank=True, null=True)
-
-    sticky = models.BooleanField(_('sticky'), default=False, db_index=True,
-                                 help_text=_('Sticky cites will take precedense.'))
-    background_plain = models.BooleanField(_('plain background'), default=False)
-    background_color = models.CharField(_('background color'), max_length=32, blank=True)
+    picture_alt = models.CharField('alternatywny tekst ilustracji', max_length=255, blank=True)
+    picture_title = models.CharField('tytuł ilustracji', max_length=255, null=True, blank=True)
+    picture_author = models.CharField('autor ilustracji', max_length=255, blank=True, null=True)
+    picture_link = models.URLField('link ilustracji', blank=True, null=True)
+    picture_license = models.CharField('nazwa licencji ilustracji', max_length=255, blank=True, null=True)
+    picture_license_link = models.URLField('adres licencji ilustracji', blank=True, null=True)
+
+    sticky = models.BooleanField('przyklejony', default=False, db_index=True,
+                                 help_text='Przyklejone cytaty mają pierwszeństwo.')
+    background_plain = models.BooleanField('jednobarwne tło', default=False)
+    background_color = models.CharField('kolor tła', max_length=32, blank=True)
     image = models.ImageField(
-        _('background image'), upload_to='social/cite', null=True, blank=True,
-        help_text=_('Best background is 975 x 315 px and under 100kB.'))
-    image_title = models.CharField(_('background title'), max_length=255, null=True, blank=True)
-    image_author = models.CharField(_('background author'), max_length=255, blank=True, null=True)
-    image_link = models.URLField(_('background link'), blank=True, null=True)
-    image_license = models.CharField(_('background license name'), max_length=255, blank=True, null=True)
-    image_license_link = models.URLField(_('background license link'), blank=True, null=True)
+        'obraz tła', upload_to='social/cite', null=True, blank=True,
+        help_text='Najlepsze tło ma wielkość 975 x 315 px i waży poniżej 100kB.')
+    image_title = models.CharField('tytuł obrazu tła', max_length=255, null=True, blank=True)
+    image_author = models.CharField('autor obrazu tła', max_length=255, blank=True, null=True)
+    image_link = models.URLField('link obrazu tła', blank=True, null=True)
+    image_license = models.CharField('nazwa licencji obrazu tła', max_length=255, blank=True, null=True)
+    image_license_link = models.URLField('adres licencji obrazu tła', blank=True, null=True)
 
-    created_at = models.DateTimeField(_('created at'), auto_now_add=True)
-    group = models.ForeignKey(BannerGroup, verbose_name=_('group'), null=True, blank=True, on_delete=models.SET_NULL)
+    created_at = models.DateTimeField('utworzony', auto_now_add=True)
+    group = models.ForeignKey(BannerGroup, verbose_name='grupa', null=True, blank=True, on_delete=models.SET_NULL)
 
     class Meta:
         ordering = ('vip', 'text')
-        verbose_name = _('banner')
-        verbose_name_plural = _('banners')
+        verbose_name = 'banner'
+        verbose_name_plural = 'bannery'
 
     def __str__(self):
         t = []
@@ -123,17 +123,17 @@ class Cite(models.Model):
 
 
 class Carousel(models.Model):
-    placement = models.SlugField(_('placement'), choices=[
+    placement = models.SlugField('miejsce', choices=[
         ('main', 'main'),
         ('main_2022', 'main 2022'),
     ])
-    priority = models.SmallIntegerField(_('priority'), default=0)
-    language = models.CharField(_('language'), max_length=2, blank=True, default='', choices=settings.LANGUAGES)
+    priority = models.SmallIntegerField('priorytet', default=0)
+    language = models.CharField('język', max_length=2, blank=True, default='', choices=settings.LANGUAGES)
 
     class Meta:
 #        ordering = ('placement', '-priority')
-        verbose_name = _('carousel')
-        verbose_name_plural = _('carousels')
+        verbose_name = 'karuzela'
+        verbose_name_plural = 'karuzele'
 
     def __str__(self):
         return self.placement
@@ -147,24 +147,26 @@ class Carousel(models.Model):
 
 
 class CarouselItem(models.Model):
-    order = models.PositiveSmallIntegerField(_('order'))
-    carousel = models.ForeignKey(Carousel, models.CASCADE, verbose_name=_('carousel'))
-    banner = models.ForeignKey(Cite, models.CASCADE, null=True, blank=True, verbose_name=_('banner'))
-    banner_group = models.ForeignKey(BannerGroup, models.CASCADE, null=True, blank=True, verbose_name=_('banner group'))
+    order = models.PositiveSmallIntegerField('kolejność')
+    carousel = models.ForeignKey(Carousel, models.CASCADE, verbose_name='karuzela')
+    banner = models.ForeignKey(
+        Cite, models.CASCADE, null=True, blank=True, verbose_name='banner')
+    banner_group = models.ForeignKey(
+        BannerGroup, models.CASCADE, null=True, blank=True, verbose_name='grupa bannerów')
 
     class Meta:
         ordering = ('order',)
-        verbose_name = _('carousel item')
-        verbose_name_plural = _('carousel items')
+        verbose_name = 'element karuzeli'
+        verbose_name_plural = 'elementy karuzeli'
 
     def __str__(self):
         return str(self.banner or self.banner_group)
 
     def clean(self):
         if not self.banner and not self.banner_group:
-            raise ValidationError(_('Either banner or banner group is required.'))
+            raise ValidationError('Proszę wskazać banner albo grupę bannerów.')
         elif self.banner and self.banner_group:
-            raise ValidationError(_('Either banner or banner group is required.'))
+            raise ValidationError('Proszę wskazać banner albo grupę bannerów.')
 
     def get_banner(self):
         return self.banner or self.banner_group.get_banner()