From 4dee434e71f79d93eebc5ad98a5fde0fc37da665 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 5 Feb 2023 18:31:36 +0100 Subject: [PATCH] domains: add missing logic to inject translated 'help' keys in config panel like we do for global settings --- locales/en.json | 2 ++ share/config_domain.toml | 5 ----- src/domain.py | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/locales/en.json b/locales/en.json index b8ca0c229..3832cb6c0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -345,9 +345,11 @@ "domain_config_cert_summary_selfsigned": "WARNING: Current certificate is self-signed. Browsers will display a spooky warning to new visitors!", "domain_config_cert_validity": "Validity", "domain_config_default_app": "Default app", + "domain_config_default_app_help": "People will automatically be redirected to this app when opening this domain. If no app is specified, people are redirected to the user portal login form.", "domain_config_mail_in": "Incoming emails", "domain_config_mail_out": "Outgoing emails", "domain_config_xmpp": "Instant messaging (XMPP)", + "domain_config_xmpp_help": "NB: some XMPP features will require that you update your DNS records and regenerate your Lets Encrypt certificate to be enabled", "domain_created": "Domain created", "domain_creation_failed": "Unable to create domain {domain}: {error}", "domain_deleted": "Domain deleted", diff --git a/share/config_domain.toml b/share/config_domain.toml index c67996d13..82ef90c32 100644 --- a/share/config_domain.toml +++ b/share/config_domain.toml @@ -9,8 +9,6 @@ name = "Features" type = "app" filter = "is_webapp" default = "_none" - # FIXME: i18n - help = "People will automatically be redirected to this app when opening this domain. If no app is specified, people are redirected to the user portal login form." [feature.mail] @@ -27,8 +25,6 @@ name = "Features" [feature.xmpp.xmpp] type = "boolean" default = 0 - # FIXME: i18n - help = "NB: some XMPP features will require that you update your DNS records and regenerate your Lets Encrypt certificate to be enabled" [dns] name = "DNS" @@ -67,7 +63,6 @@ name = "Certificate" visible = "acme_eligible == false || acme_eligible == null" [cert.cert.cert_no_checks] - ask = "Ignore diagnosis checks" type = "boolean" default = false visible = "acme_eligible == false || acme_eligible == null" diff --git a/src/domain.py b/src/domain.py index e83b5e3e8..7839b988d 100644 --- a/src/domain.py +++ b/src/domain.py @@ -624,14 +624,28 @@ class DomainConfigPanel(ConfigPanel): f"domain_config_cert_summary_{status['summary']}" ) - # Other specific strings used in config panels - # i18n: domain_config_cert_renew_help - # FIXME: Ugly hack to save the cert status and reinject it in _load_current_values ... self.cert_status = status return toml + def get(self, key="", mode="classic"): + result = super().get(key=key, mode=mode) + + if mode == "full": + for panel, section, option in self._iterate(): + # This injects: + # i18n: domain_config_cert_renew_help + # i18n: domain_config_default_app_help + # i18n: domain_config_xmpp_help + if m18n.key_exists(self.config["i18n"] + "_" + option["id"] + "_help"): + option["help"] = m18n.n( + self.config["i18n"] + "_" + option["id"] + "_help" + ) + return self.config + + return result + def _load_current_values(self): # TODO add mechanism to share some settings with other domains on the same zone super()._load_current_values()