i18n: improve translations across horilla (#1014)

- Added trans() / _() translations to models, forms and templates.
- Updated Spanish locale (django.po).
- Fixed missing verbose_name translations.

Known issues:
- "Leave Type" label in horilla/leave/forms.py not translating.
- "Performance" and "Mails automations" still pending.
This commit is contained in:
elchimeneas
2025-12-23 05:40:04 +00:00
committed by GitHub
parent 836fa4df12
commit 641a4d4842
21 changed files with 779 additions and 615 deletions

View File

@@ -5,7 +5,8 @@ from django import apps
from django.db import models
from django.db.models.signals import post_delete, post_save
from django.forms import ValidationError
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as trans
from base.horilla_company_manager import HorillaCompanyManager
from base.models import Company, Department, JobPosition, Tags
@@ -16,31 +17,32 @@ from horilla_audit.methods import get_diff
from horilla_audit.models import HorillaAuditInfo, HorillaAuditLog
PRIORITY = [
("low", "Low"),
("medium", "Medium"),
("high", "High"),
("low", trans("Low")),
("medium", trans("Medium")),
("high", trans("High")),
]
MANAGER_TYPES = [
("department", "Department"),
("job_position", "Job Position"),
("individual", "Individual"),
("department", trans("Department")),
("job_position", trans("Job Position")),
("individual", trans("Individual")),
]
TICKET_TYPES = [
("suggestion", "Suggestion"),
("complaint", "Complaint"),
("service_request", "Service Request"),
("meeting_request", "Meeting Request"),
("anounymous_complaint", "Anonymous Complaint"),
("others", "Others"),
("suggestion", trans("Suggestion")),
("complaint", trans("Complaint")),
("service_request", trans("Service Request")),
("meeting_request", trans("Meeting Request")),
("anounymous_complaint", trans("Anonymous Complaint")),
("others", trans("Others")),
]
TICKET_STATUS = [
("new", "New"),
("in_progress", "In Progress"),
("on_hold", "On Hold"),
("resolved", "Resolved"),
("canceled", "Canceled"),
("new", trans("New")),
("in_progress", trans("In Progress")),
("on_hold", trans("On Hold")),
("resolved", trans("Resolved")),
("canceled", trans("Canceled")),
]
@@ -74,9 +76,11 @@ class DepartmentManager(HorillaModel):
class TicketType(HorillaModel):
title = models.CharField(max_length=100, unique=True, verbose_name=_("Title"))
type = models.CharField(choices=TICKET_TYPES, max_length=50, verbose_name=_("Type"))
prefix = models.CharField(max_length=3, unique=True, verbose_name=_("Prefix"))
title = models.CharField(max_length=100, unique=True, verbose_name=trans("Title"))
type = models.CharField(
choices=TICKET_TYPES, max_length=50, verbose_name=trans("Type")
)
prefix = models.CharField(max_length=3, unique=True, verbose_name=trans("Prefix"))
company_id = models.ForeignKey(
Company, null=True, editable=False, on_delete=models.PROTECT
)
@@ -86,8 +90,8 @@ class TicketType(HorillaModel):
return self.title
class Meta:
verbose_name = _("Ticket Type")
verbose_name_plural = _("Ticket Types")
verbose_name = trans("Ticket Type")
verbose_name_plural = trans("Ticket Types")
class Ticket(HorillaModel):
@@ -99,7 +103,7 @@ class Ticket(HorillaModel):
ticket_type = models.ForeignKey(
TicketType,
on_delete=models.PROTECT,
verbose_name="Ticket Type",
verbose_name=trans("Ticket Type"),
)
description = models.TextField(max_length=255)
priority = models.CharField(choices=PRIORITY, max_length=100, default="low")
@@ -112,7 +116,7 @@ class Ticket(HorillaModel):
assigned_to = models.ManyToManyField(
Employee, blank=True, related_name="ticket_assigned_to"
)
deadline = models.DateField(null=True, blank=True)
deadline = models.DateField(null=True, blank=True, verbose_name=_("Deadline"))
tags = models.ManyToManyField(Tags, blank=True, related_name="ticket_tags")
status = models.CharField(choices=TICKET_STATUS, default="new", max_length=50)
history = HorillaAuditLog(
@@ -242,8 +246,10 @@ class Attachment(HorillaModel):
class FAQCategory(HorillaModel):
title = models.CharField(max_length=30)
description = models.TextField(blank=True, null=True, max_length=255)
title = models.CharField(max_length=30, verbose_name=trans("Title"))
description = models.TextField(
blank=True, null=True, max_length=255, verbose_name=trans("Description")
)
company_id = models.ForeignKey(
Company,
null=True,