From ab742e55bb0c8f1cd412162c9f240fce43217288 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 4 Jul 2024 00:04:17 +0200 Subject: [PATCH] translate _diagnosis_ignore function --- locales/en.json | 7 +++++++ src/diagnosis.py | 20 +++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/locales/en.json b/locales/en.json index 760ab3a49..8ea8f1bac 100644 --- a/locales/en.json +++ b/locales/en.json @@ -249,6 +249,13 @@ "diagnosis_http_timeout": "Timed-out while trying to contact your server from the outside. It appears to be unreachable.
1. The most common cause for this issue is that port 80 (and 443) are not correctly forwarded to your server.
2. You should also make sure that the service nginx is running
3. On more complex setups: make sure that no firewall or reverse-proxy is interfering.", "diagnosis_http_unreachable": "Domain {domain} appears unreachable through HTTP from outside the local network.", "diagnosis_ignored_issues": "(+ {nb_ignored} ignored issue(s))", + "diagnosis_ignore_already_filtered": "There is already a diagnosis {category} filter with these criterias)", + "diagnosis_ignore_no_filter_found": "(There is no such diagnosis {category} filter with these criterias to remove)", + "diagnosis_ignore_filter_added": "Added a {category} diagnosis filter", + "diagnosis_ignore_filter_removed": "Removed a {category} diagnosis filter", + "diagnosis_ignore_missing_criteria": "You should provide at least one criteria being the diagnosis category to ignore", + "diagnosis_ignore_criteria_error": "Criterias should be of the form key=value (e.g. domain=yolo.test)", + "diagnosis_ignore_no_issue_found": "No issues was found matching the given criteria.", "diagnosis_ip_broken_dnsresolution": "Domain name resolution seems to be broken for some reason… Is a firewall blocking DNS requests?", "diagnosis_ip_broken_resolvconf": "Domain name resolution seems to be broken on your server, which seems related to /etc/resolv.conf not pointing to 127.0.0.1.", "diagnosis_ip_connected_ipv4": "The server is connected to the Internet through IPv4!", diff --git a/src/diagnosis.py b/src/diagnosis.py index c56c2f22c..c47e894fe 100644 --- a/src/diagnosis.py +++ b/src/diagnosis.py @@ -263,16 +263,12 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False): # Sanity checks for the provided arguments if len(filter_) == 0: - raise YunohostValidationError( - "You should provide at least one criteria being the diagnosis category to ignore" - ) + raise YunohostValidationError(m18n.n("diagnosis_ignore_missing_criteria")) category = filter_[0] if category not in all_categories_names: raise YunohostValidationError(f"{category} is not a diagnosis category") if any("=" not in criteria for criteria in filter_[1:]): - raise YunohostValidationError( - "Criterias should be of the form key=value (e.g. domain=yolo.test)" - ) + raise YunohostValidationError(m18n.n("diagnosis_ignore_criteria_error")) # Convert the provided criteria into a nice dict criterias = {c.split("=")[0]: c.split("=")[1] for c in filter_[1:]} @@ -295,7 +291,7 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False): issue_matches_criterias(i, criterias) for i in current_issues_for_this_category ): - raise YunohostError("No issues was found matching the given criteria.") + raise YunohostError(m18n.n("diagnosis_ignore_no_issue_found")) # Make sure the subdicts/lists exists if "ignore_filters" not in configuration: @@ -305,13 +301,13 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False): if criterias in configuration["ignore_filters"][category]: logger.warning( - f"(There is already a diagnosis {category} filter with these criterias)" + m18n.n("diagnosis_ignore_already_filtered", service=category) ) return configuration["ignore_filters"][category].append(criterias) _diagnosis_write_configuration(configuration) - logger.success(f"Added a {category} diagnosis filter") + logger.success(m18n.n("diagnosis_ignore_filter_added", service=category)) return if remove_filter: @@ -324,14 +320,12 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False): configuration["ignore_filters"][category] = [] if criterias not in configuration["ignore_filters"][category]: - logger.warning( - f"(There is no such diagnosis {category} filter with these criterias to remove)" - ) + logger.warning(m18n.n("diagnosis_ignore_no_filter_found", service=category)) return configuration["ignore_filters"][category].remove(criterias) _diagnosis_write_configuration(configuration) - logger.success(f"Removed a {category} diagnosis filter") + logger.success(m18n.n("diagnosis_ignore_filter_removed", service=category)) return