From 17ff564eeb18697297674286499d1215ea246e5e Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 9 Jan 2025 21:29:42 -0800 Subject: [PATCH] email: Fix regression error when installing/operation app - In tags cleanup code, the front page shortcut for email uses different tags than those provided in the manifest. When the app is instantiated in privileged code without setting up Django, this causes an error even though gettext_noop is used. Workaround by using a custom method for this. Tests: - Installing, enabling/disabling email apps works. - 'make update-translations' output shows that django.pot has been updated and the tags in question are part of the POT file. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/email/__init__.py | 3 +-- plinth/utils.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plinth/modules/email/__init__.py b/plinth/modules/email/__init__.py index 8ba8039e0..f7763c3e5 100644 --- a/plinth/modules/email/__init__.py +++ b/plinth/modules/email/__init__.py @@ -5,7 +5,6 @@ import logging from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ -from django.utils.translation import gettext_noop import plinth.app from plinth import cfg, frontpage, menu @@ -19,7 +18,7 @@ from plinth.modules.letsencrypt.components import LetsEncrypt from plinth.package import Packages from plinth.privileged import service as service_privileged from plinth.signals import domain_added, domain_removed -from plinth.utils import format_lazy +from plinth.utils import format_lazy, gettext_noop from . import aliases, manifest, privileged diff --git a/plinth/utils.py b/plinth/utils.py index 565dbc09f..c7a8906d7 100644 --- a/plinth/utils.py +++ b/plinth/utils.py @@ -192,3 +192,8 @@ class SafeFormatter(string.Formatter): return super().get_field(field_name, args, kwargs) except (AttributeError, TypeError): return (f'?{field_name}?', '') + + +def gettext_noop(message: str) -> str: + """Do nothing. Using this method marks the string for translation.""" + return message