From 1ba55e793f1ceed491275df7d96adc9c7e37f1f7 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa This means that devices on the '
'internet can reach you when you are connected on the '
@@ -307,33 +304,34 @@ class InternetConnectionTypeForm(forms.Form):
'different IP address, especially after some offline time. '
'Many ISPs offer this type of connectivity. If you have a '
'public IP address but are unsure if it changes over time '
- 'or not, it is safer to choose this option.
This means that devices on the ' - 'Internet can reach you when you are connected on the ' - 'Internet. Every time you connect to the Internet with ' - 'your Internet Service Provider (ISP), you always get the ' - 'same IP address. This is the most trouble free setup for ' - 'many {box_name} services but very few ISPs offer this. ' - 'You may be able to get this service from your ISP by ' - 'making an additional payment.
'), - box_name=cfg.box_name))), + format_lazy( + _('I have a public IP address that does not change overtime ' + '(recommended)' + 'This means that devices on the ' + 'Internet can reach you when you are connected on the ' + 'Internet. Every time you connect to the Internet with ' + 'your Internet Service Provider (ISP), you always get the ' + 'same IP address. This is the most trouble-free setup for ' + 'many {box_name} services but very few ISPs offer this. ' + 'You may be able to get this service from your ISP by ' + 'making an additional payment.
'), box_name=cfg.box_name, + allow_markup=True)), ('private_ip', - Markup(format_lazy( - _('I dont have a public IP address' - 'This means that devices on the ' - 'Internet can not reach you when you are connected ' - 'to the Internet. Every time you connect to the Internet ' - 'with your Internet Service Provider (ISP), you get an IP ' - 'address that is only relevant for local networks. ' - 'Many ISPs offer this type of connectivity. This is the ' - 'most troublesome situation for hosting services at home. ' - '{box_name} provides many workaround solutions but each ' - 'solution has some limitations.
'), - box_name=cfg.box_name))), + format_lazy( + _('I dont have a public IP address' + 'This means that devices on the ' + 'Internet can not reach you when you are connected ' + 'to the Internet. Every time you connect to the Internet ' + 'with your Internet Service Provider (ISP), you get an IP ' + 'address that is only relevant for local networks. ' + 'Many ISPs offer this type of connectivity. This is the ' + 'most troublesome situation for hosting services at home. ' + '{box_name} provides many workaround solutions but each ' + 'solution has some limitations.
'), + box_name=cfg.box_name, allow_markup=True)), ], required=True, widget=forms.RadioSelect, @@ -351,7 +349,7 @@ class RouterConfigurationWizardForm(forms.Form): choices=[ ( 'dmz', - Markup(format_lazy( + format_lazy( _('Use DMZ feature to forward all traffic' 'Most routers provide a ' 'configuration setting called DMZ. This will allow the ' @@ -359,37 +357,31 @@ class RouterConfigurationWizardForm(forms.Form): 'internet to a single IP address such as the ' '{box_name}\'s address. First remember to configure a ' 'static local IP address for your {box_name} in your ' - 'router\'s configuration.
'), - box_name=cfg.box_name - )), - ), - ( - 'port_forwarding', - Markup(format_lazy( - _('Forward Specific Traffic as needed by each ' - 'application' - 'You may alternatively choose to ' - 'forward only specific traffic to your {box_name}. ' - 'This is ideal if you have other servers like ' - '{box_name} in your network or if your router does not ' - 'support DMZ feature. All applications that provide a ' - 'web interface need you to forward traffic from ports ' - '80 and 443 to work. Each of the other applications ' - 'will suggest which port(s) need to be forwarded ' - 'for that application to work.
'), - box_name=cfg.box_name - )) - ), - ( - 'not_configured', - Markup( - _('Router is currently unconfigured' - 'Choose this if you have not ' - 'configured or are unable to configure the router ' - 'currently and wish to be reminded later. Some of ' - 'the other configuration steps may fail.
') - ) + 'router\'s configuration.'), box_name=cfg.box_name, + allow_markup=True), ), + ('port_forwarding', + format_lazy( + _('Forward Specific Traffic as needed by each ' + 'application' + 'You may alternatively choose to ' + 'forward only specific traffic to your {box_name}. ' + 'This is ideal if you have other servers like ' + '{box_name} in your network or if your router does not ' + 'support DMZ feature. All applications that provide a ' + 'web interface need you to forward traffic from ports ' + '80 and 443 to work. Each of the other applications ' + 'will suggest which port(s) need to be forwarded ' + 'for that application to work.
'), box_name=cfg.box_name, + allow_markup=True)), + ('not_configured', + format_lazy( + _('Router is currently unconfigured' + 'Choose this if you have not ' + 'configured or are unable to configure the router ' + 'currently and wish to be reminded later. Some of ' + 'the other configuration steps may fail.
'), + allow_markup=True)), ], required=True, widget=forms.RadioSelect, diff --git a/plinth/utils.py b/plinth/utils.py index cf238411b..f4392ef31 100644 --- a/plinth/utils.py +++ b/plinth/utils.py @@ -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)