summaryrefslogtreecommitdiff
path: root/src/mailman/chains/base.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-07-26 23:24:18 +0000
committerBarry Warsaw2017-07-26 23:24:18 +0000
commitade94e8f833a9472ba9be52a08f4e2f381e7a212 (patch)
tree5fba570b0c6f4c0919009cb6f455c18bc732192a /src/mailman/chains/base.py
parent02826321d0430d7ffc1f674eeff4221941689ef7 (diff)
parentbea94cb9538a55b1376afd42c2ce751efce62cfe (diff)
downloadmailman-ade94e8f833a9472ba9be52a08f4e2f381e7a212.tar.gz
mailman-ade94e8f833a9472ba9be52a08f4e2f381e7a212.tar.zst
mailman-ade94e8f833a9472ba9be52a08f4e2f381e7a212.zip
Diffstat (limited to 'src/mailman/chains/base.py')
-rw-r--r--src/mailman/chains/base.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mailman/chains/base.py b/src/mailman/chains/base.py
index 59125ba69..9507d8fbc 100644
--- a/src/mailman/chains/base.py
+++ b/src/mailman/chains/base.py
@@ -18,6 +18,7 @@
"""Base class for terminal chains."""
from mailman.config import config
+from mailman.core.i18n import _
from mailman.interfaces.chain import (
IChain, IChainIterator, IChainLink, IMutableChain, LinkAction)
from mailman.interfaces.rules import IRule
@@ -27,6 +28,24 @@ from zope.interface import implementer
@public
+def format_reasons(reasons):
+ """Translate and format hold and rejection reasons.
+
+ :param reasons: A list of reasons from the rules that hit. Each reason is
+ a string to be translated or a tuple consisting of a string with {}
+ replacements and one or more replacement values.
+ :returns: A list of the translated and formatted strings.
+ """
+ new_reasons = []
+ for reason in reasons:
+ if isinstance(reason, tuple):
+ new_reasons.append(_(reason[0]).format(*reason[1:]))
+ else:
+ new_reasons.append(_(reason))
+ return new_reasons
+
+
+@public
@implementer(IChainLink)
class Link:
"""A chain link."""