diff --git a/pflaenzli/pflaenzli/forms.py b/pflaenzli/pflaenzli/forms.py index 2e7d651..8776e98 100644 --- a/pflaenzli/pflaenzli/forms.py +++ b/pflaenzli/pflaenzli/forms.py @@ -2,6 +2,7 @@ from django import forms from django.contrib.auth.forms import UserCreationForm from django.utils.safestring import mark_safe from friendly_captcha.fields import FrcCaptchaField +from django.utils.translation import gettext_lazy as _ from .models import Offer, PflaenzliUser, Wish @@ -22,11 +23,11 @@ class RegistrationForm(UserCreationForm): class FilterForm(forms.Form): text = forms.CharField(max_length=128, required=False, label=mark_safe( - ' Search')) + f' {_("Search")}')) zipcode = forms.CharField(max_length=4, required=False, label=mark_safe( - ' Zipcode')) + f' {_("ZIP code")}')) distance = forms.IntegerField(required=False, label=mark_safe( - ' Distance (km)')) + f' {_("Entfernung")} (km)')) class WishForm(forms.ModelForm): diff --git a/pflaenzli/pflaenzli/mail.py b/pflaenzli/pflaenzli/mail.py index d2a8504..8095fa2 100644 --- a/pflaenzli/pflaenzli/mail.py +++ b/pflaenzli/pflaenzli/mail.py @@ -1,6 +1,7 @@ from django.core.mail import EmailMessage, EmailMultiAlternatives from django.urls import reverse from django.template.loader import render_to_string +from django.utils.translation import gettext_lazy as _ def send_offer_email(request, offer, sender_user, recipient_user): @@ -9,7 +10,7 @@ def send_offer_email(request, offer, sender_user, recipient_user): plain_text = get_offer_text(request, offer, sender_user, recipient_user) message = EmailMultiAlternatives( - f'{sender_user.username} wants to trade', + f'{sender_user.username} {_("wants to trade")}', plain_text, 'no-reply@pflaenz.li', [recipient_user.email], @@ -22,4 +23,4 @@ def send_offer_email(request, offer, sender_user, recipient_user): def get_offer_text(request, offer, sender_user, recipient_user): - return f"Hello {recipient_user.username},\n\nThe user {sender_user.username} would like to trade '{offer.title}' with you!\n\nIf you would like to trade with {sender_user.username}, just reply to this email to get in touch with them.\n\nYou can also view their offers here: {request.scheme}://{request.get_host()}{reverse('user_detail', args=[sender_user.id])}" + return f"{_('Hello')} {recipient_user.username},\n\n{sender_user.username} {_('is interested in')} {offer.title}!\n\n{_('Checkout their offers')}: {request.scheme}://{request.get_host()}{reverse('user_detail', args=[sender_user.id])}\n\n{_('Contact')} {sender_user.username}, {_('by replying to this mail')}." diff --git a/pflaenzli/pflaenzli/models.py b/pflaenzli/pflaenzli/models.py index c9055a3..a4a7266 100644 --- a/pflaenzli/pflaenzli/models.py +++ b/pflaenzli/pflaenzli/models.py @@ -5,26 +5,27 @@ from django.dispatch import receiver from django.contrib.auth.models import AbstractUser from django.utils import timezone from django.core.files.storage import default_storage +from django.utils.translation import gettext_lazy as _ class PflaenzliUser(AbstractUser): email = models.EmailField(max_length=254) - zipcode = models.PositiveIntegerField(blank=True, null=True) + zipcode = models.PositiveIntegerField(blank=True, null=True, verbose_name=_('ZIP Code')) class Offer(models.Model): created = models.DateTimeField(default=timezone.now) user = models.ForeignKey(PflaenzliUser, on_delete=models.CASCADE) - title = models.CharField(max_length=50) - description = models.TextField(max_length=5000) - zipcode = models.IntegerField(blank=True, default=0) - image = models.ImageField(upload_to="uploads/") + title = models.CharField(max_length=50, verbose_name=_('Title')) + description = models.TextField(max_length=5000, verbose_name=_('Description')) + zipcode = models.IntegerField(blank=True, default=0, verbose_name=_('ZIP Code')) + image = models.ImageField(upload_to="uploads/", verbose_name=_('Image')) class Wish(models.Model): created = models.DateTimeField(default=timezone.now) user = models.ForeignKey(PflaenzliUser, on_delete=models.CASCADE) - title = models.CharField(max_length=200) + title = models.CharField(max_length=200, verbose_name=_('Title')) @receiver(models.signals.post_delete, sender=Offer) diff --git a/pflaenzli/pflaenzli/templates/app/index.html b/pflaenzli/pflaenzli/templates/app/index.html index 7374ee5..adb67bf 100644 --- a/pflaenzli/pflaenzli/templates/app/index.html +++ b/pflaenzli/pflaenzli/templates/app/index.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load static %} +{% load i18n %} {% block title %}Home{% endblock %} {% block meta %}{% endblock %} {% block background %}home-background{% endblock %} @@ -9,18 +10,18 @@
- This is a platform to trade plants. You can offer plants and setup a wishlist what you want to trade it for. + {% trans "This is a platform to trade plants. You can offer plants and setup a wishlist what you want to trade it for." %}
To offer your plants, please register first.
+{% trans "To offer your plants, please register first." %}
Show Offers + type="button">{% trans "Offers" %} Register + type="button">{% trans "Register" %}{{ offer.description }}
{{ offer.user.username }} would like some of the following in return:
+{{ offer.user.username }} {% trans "would like some of the following in return" %}:
- Please confirm your email address by clicking the following link:
- Confirm my Email.
- This link will expire in {{ expiresAtMessageKey|trans(expiresAtMessageData, 'VerifyEmailBundle') }}.
-
- Cheers!
+ {% trans "Please confirm your email address by clicking the following link" %}:
+
+
+ {% trans "Confirm my email" %}.
+ {% trans "This link will expire in" %} {{ expiresAtMessageKey|trans(expiresAtMessageData, 'VerifyEmailBundle') }}.
Cheers!
diff --git a/pflaenzli/pflaenzli/templates/registration/login.html b/pflaenzli/pflaenzli/templates/registration/login.html index c5752c9..382ea9a 100644 --- a/pflaenzli/pflaenzli/templates/registration/login.html +++ b/pflaenzli/pflaenzli/templates/registration/login.html @@ -1,11 +1,14 @@ {% extends "base.html" %} +{% load i18n %} {% load crispy_forms_tags %} {% block content %} {% if next %} {% if user.is_authenticated %} -Your account doesn't have access to this page. To proceed, please login with an account that has access.
+Please login to see this page.
+- Forgot password? + {% trans "Forgot password?" %}
{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html b/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html index 62bcc1e..9c44067 100644 --- a/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html +++ b/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} +{% load i18n %} {% block content %} -New password was set successfully. Please login again.
+{% trans "New password was set successfully. Please login again." %}
{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html b/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html index 935354f..c808cfa 100644 --- a/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html +++ b/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html @@ -1,8 +1,9 @@ {% extends 'base.html' %} +{% load i18n %} {% load crispy_forms_tags %} {% block content %} -Choose a new password.
+{% trans "Choose a new password." %}