diff --git a/plinth/daemon.py b/plinth/daemon.py index eb64eba3b..144eb85d4 100644 --- a/plinth/daemon.py +++ b/plinth/daemon.py @@ -7,7 +7,8 @@ import socket import subprocess import psutil -from django.utils.translation import ugettext as _ +from django.utils.text import format_lazy +from django.utils.translation import ugettext as _, ugettext_lazy from plinth import action_utils, actions, app @@ -82,10 +83,12 @@ class Daemon(app.LeaderComponent): def _diagnose_unit_is_running(self): """Check if a daemon is running.""" - message = _('Service {service_name} is running').format( - service_name=self.unit) result = 'passed' if self.is_running() else 'failed' - return [message, result] + + template = ugettext_lazy('Service {service_name} is running') + testname = format_lazy(template, service_name=self.unit) + + return [testname, result] def app_is_running(app_): @@ -108,13 +111,15 @@ def diagnose_port_listening(port, kind='tcp', listen_address=None): result = _check_port(port, kind, listen_address) if listen_address: - test = _('Listening on {kind} port {listen_address}:{port}') \ - .format(kind=kind, listen_address=listen_address, port=port) + template = ugettext_lazy( + 'Listening on {kind} port {listen_address}:{port}') + testname = format_lazy(template, kind=kind, + listen_address=listen_address, port=port) else: - test = _('Listening on {kind} port {port}') \ - .format(kind=kind, port=port) + template = ugettext_lazy('Listening on {kind} port {port}') + testname = format_lazy(template, kind=kind, port=port) - return [test, 'passed' if result else 'failed'] + return [testname, 'passed' if result else 'failed'] def _check_port(port, kind='tcp', listen_address=None): diff --git a/plinth/modules/apache/components.py b/plinth/modules/apache/components.py index b6e0afccb..82cf0284a 100644 --- a/plinth/modules/apache/components.py +++ b/plinth/modules/apache/components.py @@ -6,13 +6,15 @@ App component for other apps to use Apache configuration functionality. import re import subprocess -from django.utils.translation import ugettext as _ +from django.utils.text import format_lazy +from django.utils.translation import ugettext_lazy from plinth import action_utils, actions, app class Webserver(app.LeaderComponent): """Component to enable/disable Apache configuration.""" + def __init__(self, component_id, web_name, kind='config', urls=None): """Initialize the web server component. @@ -71,6 +73,7 @@ class Webserver(app.LeaderComponent): class Uwsgi(app.LeaderComponent): """Component to enable/disable uWSGI configuration.""" + def __init__(self, component_id, uwsgi_name): """Initialize the uWSGI component. @@ -116,12 +119,13 @@ def diagnose_url(url, kind=None, env=None, check_certificate=True, wrapper, expected_output) if kind: - return [ - _('Access URL {url} on tcp{kind}').format(url=url, kind=kind), - result - ] + template = ugettext_lazy('Access URL {url} on tcp{kind}') + testname = format_lazy(template, url=url, kind=kind) + else: + template = ugettext_lazy('Access URL {url}') + testname = format_lazy(template, url=url) - return [_('Access URL {url}').format(url=url), result] + return [testname, result] def diagnose_url_on_all(url, **kwargs): diff --git a/plinth/modules/diagnostics/__init__.py b/plinth/modules/diagnostics/__init__.py index 43a23b4d2..dc9805a8d 100644 --- a/plinth/modules/diagnostics/__init__.py +++ b/plinth/modules/diagnostics/__init__.py @@ -129,7 +129,11 @@ def run_on_all_enabled_modules(): current_results['apps'] = apps for current_index, (app_id, app) in enumerate(apps): - current_results['results'][app_id] = app.diagnose() + app_name = app.info.name or _('None') + current_results['results'][app_id] = { + 'name': app_name, + 'results': app.diagnose() + } current_results['progress_percentage'] = \ int((current_index + 1) * 100 / len(apps)) diff --git a/plinth/modules/diagnostics/templates/diagnostics.html b/plinth/modules/diagnostics/templates/diagnostics.html index e87525db6..6e8ac9422 100644 --- a/plinth/modules/diagnostics/templates/diagnostics.html +++ b/plinth/modules/diagnostics/templates/diagnostics.html @@ -37,11 +37,15 @@ {{ results.error }} {% else %} - {% for app_id, app_results in results.results.items %} -
{% endif %} diff --git a/plinth/modules/diagnostics/templates/diagnostics_results.html b/plinth/modules/diagnostics/templates/diagnostics_results.html index 04c684b93..b34c8a976 100644 --- a/plinth/modules/diagnostics/templates/diagnostics_results.html +++ b/plinth/modules/diagnostics/templates/diagnostics_results.html @@ -15,7 +15,7 @@ {% for test, result in results %}