fix: translations

This commit is contained in:
Pablo Moreno
2025-01-17 21:25:51 +01:00
parent 551096b2c0
commit ae26a8d09c
10 changed files with 452 additions and 573 deletions
+7 -1
View File
@@ -1,6 +1,7 @@
import datetime
from config.settings.environ import * # noqa
from django.utils.text import gettext_lazy as _
APP_NAME = "Shop"
DESCRIPTION = ""
@@ -122,7 +123,12 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = "es-es"
LANGUAGE_CODE = "es"
LANGUAGES = (
("en", _("Inglés")),
("es", _("Castellano")),
)
TIME_ZONE = "Europe/Madrid"
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -6,11 +6,11 @@ from web.mixins import StylingMixin
class LoginForm(StylingMixin, AuthenticationForm):
styled_fields = ['username', 'password', ]
placeholder_for_field = {
"username": _("pablo@shoppy.com"),
"password": "********"
}
styled_fields = [
"username",
"password",
]
placeholder_for_field = {"username": _("pablo@shoppy.com"), "password": "********"}
username = UsernameField(
widget=forms.EmailInput(
+1 -1
View File
@@ -11,7 +11,7 @@ class RegisterForm(StylingMixin, BaseUserCreationForm, SetPasswordMixin):
password1, password2 = SetPasswordMixin.create_password_fields()
styled_fields = ["email", "first_name", "last_name", "password1", "password2"]
placeholder_for_field = {
"email": _('pablo@shoppy.com'),
"email": _("pablo@shoppy.com"),
"first_name": _("Pablo"),
"last_name": _("Moreno"),
"password1": "********",
+8 -3
View File
@@ -9,14 +9,19 @@ from web.mixins import StylingMixin
class PasswordResetForm(StylingMixin, BasePasswordResetForm):
styled_fields = ['email', ]
styled_fields = [
"email",
]
placeholder_for_field = {
"email": _("pablo@shoppy.com"),
}
class SetPasswordForm(StylingMixin, BaseSetPasswordForm):
styled_fields = ['new_password1', 'new_password2', ]
styled_fields = [
"new_password1",
"new_password2",
]
placeholder_for_field = {
"new_password1": "********",
"new_password2": "********",
@@ -40,6 +45,6 @@ class SetPasswordForm(StylingMixin, BaseSetPasswordForm):
try:
self.validate_token()
except ValidationError as e:
self.add_error('token', str(e))
self.add_error("token", str(e))
return False
return super().is_valid()
@@ -6,9 +6,7 @@
class="inline-flex items-center rounded-lg justify-center p-2 hover:bg-gray-100 dark:hover:bg-gray-700 text-sm font-medium leading-none text-gray-900 dark:text-white">
{% include 'components/icons/cart.svg' %}
<span class="hidden sm:flex">
{% blocktranslate %}
Carrito
{% endblocktranslate %}</span>
{% translate 'Carrito' %}</span>
<span class="ml-1">({{ cart.items.count }})</span>
</button>
@@ -0,0 +1,26 @@
<div id="toast-default"
class="flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800"
role="alert"
>
<div class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200">
{% block icon %}
{% endblock %}
</div>
<div class="ms-3 text-sm font-normal">
{% block toast_text %}{% endblock %}
</div>
<button type="button"
class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2
focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8
dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700"
data-dismiss-target="#toast-default" aria-label="Close"
hx-on:click="htmx.toggleClass(htmx.find('#toast-default'), 'hidden')"
>
<span class="sr-only">{% translate 'Cerrar' %}</span>
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
</button>
</div>
+8 -3
View File
@@ -60,10 +60,15 @@ class LoginView(View, RedirectionMixin):
return redirect(self.get_redirection())
return render(request, self.template_name, {
return render(
request,
self.template_name,
{
"form": login_form,
"errors": login_form.errors.get('__all__'),
}, status=400)
"errors": login_form.errors.get("__all__"),
},
status=400,
)
class RegisterView(TemplateView, RedirectionMixin):
+2 -2
View File
@@ -45,7 +45,7 @@ class CategoryView(TemplateView):
category = ProductCategory.objects.get(slug=slug)
return {
"title": _(f'{settings.web_title} - {category.name}'),
"title": _(f"{settings.web_title} - {category.name}"),
"description": settings.web_description,
"category": category,
"filter_by_category": True,
@@ -61,7 +61,7 @@ class ProductDetail(TemplateView):
return {
"product": product,
"title": f'{settings.web_title} - {product.name}',
"title": f"{settings.web_title} - {product.name}",
"description": product.description,
"image": product.images.first(),
}