From e9adc5ce687969a27dae21d48c67ea5eca528259 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 18 Oct 2024 15:53:08 -0700 Subject: [PATCH] setup: Translate errors when installing/updating/repairing apps - Currently, we are taking a error string and formatting it before it can be looked up for translation. This causes the lookups to always fail. - Don't format the error messages and send them as is. Let the Operation.translate_message and Notification take care of translation. Formatting will be them after translation. Set the formatting keys as they need so that exception string is inserted into the message Tests: - Set language to Spanish. Through code changes raise an exception in bepasty.privileged.setup(). Try to install bepasty app. Setup will fail and error message will shown. The error message will be localized and formatted with the patch. This is true in the app error message and in the notification. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/setup.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plinth/setup.py b/plinth/setup.py index af19995fa..3ae80ea67 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -75,14 +75,11 @@ def _run_setup_on_app(app, current_version, repair: bool = False): except Exception as exception: exception_to_update = exception if not current_version: - message = gettext_noop('Error installing app: {error}').format( - error=exception) + message = gettext_noop('Error installing app: {exception}') elif repair: - message = gettext_noop('Error repairing app: {error}').format( - error=exception) + message = gettext_noop('Error repairing app: {exception}') else: - message = gettext_noop('Error updating app: {error}').format( - error=exception) + message = gettext_noop('Error updating app: {exception}') else: if not current_version: message = gettext_noop('App installed.') @@ -320,8 +317,8 @@ def _get_apps_for_regular_setup(): 1. essential apps that are not up-to-date 2. non-essential app that are installed and need updates """ - if (app.info.is_essential and app.get_setup_state() - != app_module.App.SetupState.UP_TO_DATE): + if (app.info.is_essential and + app.get_setup_state() != app_module.App.SetupState.UP_TO_DATE): return True if app.get_setup_state() == app_module.App.SetupState.NEEDS_UPDATE: