diff options
| author | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
| commit | 324226f1f859f6be5e932dc9abe638aba268d154 (patch) | |
| tree | f021166b8c82bb02feff82a9360ba61a44b804ee /src/mailman/core/i18n.py | |
| parent | e6326533b78290514ede917ed1cb95804759a45a (diff) | |
| parent | 9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6 (diff) | |
| download | mailman-324226f1f859f6be5e932dc9abe638aba268d154.tar.gz mailman-324226f1f859f6be5e932dc9abe638aba268d154.tar.zst mailman-324226f1f859f6be5e932dc9abe638aba268d154.zip | |
Diffstat (limited to 'src/mailman/core/i18n.py')
| -rw-r--r-- | src/mailman/core/i18n.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mailman/core/i18n.py b/src/mailman/core/i18n.py index 69abe3b9d..d5aa06b5c 100644 --- a/src/mailman/core/i18n.py +++ b/src/mailman/core/i18n.py @@ -47,3 +47,21 @@ def initialize(application=None): def handle_ConfigurationUpdatedEvent(event): if isinstance(event, ConfigurationUpdatedEvent): _.default = event.config.mailman.default_language + + +@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 |
