mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
networks: Fix i18n for wizard forms
- Using Markup on format_lazy objects seems to convert negate their lazy behavior. - Extend the format_lazy() utility method to handle markup. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
2 files changed
+70
-72
No files matched your search
+7
-1
@@ -11,6 +11,7 @@ import re
|
||||
import string
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
import markupsafe
|
||||
import ruamel.yaml
|
||||
from django.utils.functional import lazy
|
||||
|
||||
@@ -33,8 +34,13 @@ def import_from_gi(library, version):
|
||||
|
||||
def _format_lazy(string, *args, **kwargs):
|
||||
"""Lazily format a lazy string."""
|
||||
allow_markup = kwargs.pop('allow_markup', False)
|
||||
string = str(string)
|
||||
return string.format(*args, **kwargs)
|
||||
string = string.format(*args, **kwargs)
|
||||
if allow_markup:
|
||||
string = markupsafe.Markup(string)
|
||||
|
||||
return string
|
||||
|
||||
|
||||
format_lazy = lazy(_format_lazy, str)
|
||||
|
||||
Reference in new issue
Block a user