Commit 46c59d71 authored by Alan's avatar Alan
Browse files

ASP: better wording when more than one package is installed

Refs: #15381
parent 7eb66334
......@@ -199,6 +199,19 @@ def _spawn_daemon(func):
func()
def _format_list(lst):
"""Return a nice formatted version of list."""
lst = sorted(lst)
if len(lst) == 1:
return lst[0]
elif len(lst) > 1:
return "{beginning} and {last}".format(beginning=", ".join(lst[:-1]),
last=lst[-1])
else:
return str(lst)
def has_additional_packages_list(search_new_persistence=False):
"""Return true iff a packages list file is found in a persistence.
......@@ -259,7 +272,7 @@ def handle_installed_packages(packages):
logging.info("New packages manually installed: %s" % packages)
if has_unlocked_persistence(search_new_persistence=True):
if _notify(_("Add {packages} to your additional software?").format(
packages=" ".join(packages)),
packages=_format_list(packages)),
_("To install it automatically from your persistent "
"storage when starting Tails."),
_("Add to Persistent Storage"),
......@@ -287,7 +300,7 @@ def handle_installed_packages(packages):
"additional software.")
elif is_tails_media_writable():
if _notify(_("Add {packages} to your additional software?").format(
packages=" ".join(packages)),
packages=_format_list(packages)),
_("To install it automatically when starting Tails, you "
"can create a persistent storage and activate the "
"<b>Additional Software</b> feature."),
......@@ -307,7 +320,8 @@ def handle_installed_packages(packages):
if not os.path.isfile(ASP_STATE_INSTALLER_ASKED):
open(ASP_STATE_INSTALLER_ASKED, 'a').close()
_notify(_("You could install {packages} automatically when "
"starting Tails").format(packages=" ".join(packages)),
"starting Tails").format(
packages=_format_list(packages)),
_("To do so, you need to run Tails from a USB stick "
"installed using <i>Tails Installer</i>."),
documentation_target="install/clone",
......@@ -322,7 +336,7 @@ def handle_removed_packages(packages):
"""
logging.info("Additional packages removed: %s" % packages)
if _notify(_("Remove {packages} from your additional software?").format(
packages=" ".join(packages)),
packages=_format_list(packages)),
"",
_("Remove"),
_("Cancel"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment