diff --git a/board/models.py b/board/models.py index c3286cf..ae196b0 100644 --- a/board/models.py +++ b/board/models.py @@ -9,6 +9,7 @@ from django.core.files.base import ContentFile from django.dispatch import receiver from django.urls import reverse from django.utils import timezone +from django.utils.translation import gettext as _ from PIL import Image from io import BytesIO @@ -152,11 +153,11 @@ class Post(models.Model): # Make sure there is at least some content self.text = self.text.strip() if not (self.text or self.image): - raise ValidationError("Please either write a message or upload an image") + raise ValidationError(_("Please either write a message or upload an image")) # Image upload size check if self.image and self.image.size > settings.MAX_UPLOAD_SIZE: raise ValidationError( - "Image supplied is too large. Maximum image size is %(max)s", + _("Image supplied is too large. Maximum image size is %(max)s"), params={"max": settings.MAX_UPLOAD_SIZE}, ) # Rate limiting for posts @@ -169,7 +170,8 @@ class Post(models.Model): if delta < self.board.post_cooldown: cooldown = self.board.post_cooldown - delta raise ValidationError( - f"Please wait {int(cooldown.total_seconds())} seconds before posting again" + _(f"Please wait %(cooldown)s seconds before posting again"), + params={"cooldown": int(cooldown.total_seconds())}, ) diff --git a/board/templates/board/board_detail.html b/board/templates/board/board_detail.html index bf56a8d..88d1f65 100644 --- a/board/templates/board/board_detail.html +++ b/board/templates/board/board_detail.html @@ -1,5 +1,6 @@ {% extends "board/base.html" %} {% load post_body %} +{% load l10n %} {% block title %} {% with title=board.url %} @@ -22,15 +23,21 @@
| Max image size: {{ max_upload_size|measure_bytes }} | |
| + | + {% localize on %}Max image size{% endlocalize %}: + {{ max_upload_size|measure_bytes }} + | +
|---|---|