i18n: add i18n for domain and global config panel and sections

This commit is contained in:
Alexandre Aubin 2024-08-20 18:17:02 +02:00
parent 9973cc703d
commit ff03885564
6 changed files with 50 additions and 40 deletions

View file

@ -364,6 +364,10 @@
"domain_config_custom_css_help": "This is for advanced admins willing to customize the appearance of the portal",
"domain_config_portal_logo": "Custom logo",
"domain_config_portal_logo_help": "Accept .svg, .png and .jpeg. Prefer a monochrome .svg with <code>fill: currentColor</code> so that the logo adapts to the themes.",
"domain_config_feature_name": "Features",
"domain_config_portal_name": "Portal customization",
"domain_config_dns_name": "DNS",
"domain_config_cert_name": "Certificate",
"domain_config_portal_public_intro": "Custom public intro",
"domain_config_portal_public_intro_help": "You can use HTML, basic styles will be applied to generic elements.",
"domain_config_portal_theme": "Default theme",
@ -476,6 +480,20 @@
"global_settings_setting_webadmin_allowlist_enabled": "Enable Webadmin IP allowlist",
"global_settings_setting_webadmin_allowlist_enabled_help": "Allow only some IPs to access the webadmin.",
"global_settings_setting_webadmin_allowlist_help": "IP adresses allowed to access the webadmin. CIDR notation is allowed.",
"global_settings_setting_security_name": "Security",
"global_settings_setting_password_name": "Passwords",
"global_settings_setting_ssh_name": "SSH",
"global_settings_setting_nginx_name": "NGINX (web server)",
"global_settings_setting_postfix_name": "Postfix (SMTP email server)",
"global_settings_setting_webadmin_name": "Webadmin",
"global_settings_setting_root_access_name": "Change root password",
"global_settings_setting_experimental_name": "Experimental",
"global_settings_setting_email_name": "Email",
"global_settings_setting_pop3_name": "POP3",
"global_settings_setting_smtp_name": "SMTP",
"global_settings_setting_misc_name": "Other",
"global_settings_setting_backup_name": "Backup",
"global_settings_setting_network_name": "Network",
"good_practices_about_admin_password": "You are now about to define a new administration password. The password should be at least 8 characters long—though it is good practice to use a longer password (i.e. a passphrase) and/or to use a variation of characters (uppercase, lowercase, digits and special characters).",
"good_practices_about_user_password": "You are now about to define a new user password. The password should be at least 8 characters long—though it is good practice to use a longer password (i.e. a passphrase) and/or to a variation of characters (uppercase, lowercase, digits and special characters).",
"group_already_exist": "Group {group} already exists",

View file

@ -142,13 +142,20 @@ def find_expected_string_keys():
"portal_theme",
"portal_user_intro",
"search_engine",
"custom_css",
"dns",
"enable_public_apps_page",
]
for panel in domain_config.values():
domain_section_with_no_name = ["app", "cert_", "mail", "registrar"]
for panel_key, panel in domain_config.items():
if not isinstance(panel, dict):
continue
for section in panel.values():
yield f"domain_config_{panel_key}_name"
for section_key, section in panel.items():
if not isinstance(section, dict):
continue
if section_key not in domain_section_with_no_name:
yield f"domain_config_{section_key}_name"
for key, values in section.items():
if not isinstance(values, dict):
continue
@ -171,12 +178,14 @@ def find_expected_string_keys():
"root_password_confirm",
]
for panel in global_config.values():
for panel_key, panel in global_config.items():
if not isinstance(panel, dict):
continue
for section in panel.values():
yield f"global_settings_setting_{panel_key}_name"
for section_key, section in panel.items():
if not isinstance(section, dict):
continue
yield f"global_settings_setting_{section_key}_name"
for key, values in section.items():
if not isinstance(values, dict):
continue

View file

@ -2,7 +2,6 @@ version = "1.0"
i18n = "domain_config"
[feature]
name = "Features"
[feature.mail]
[feature.mail.mail_out]
@ -21,7 +20,6 @@ name = "Features"
[feature.portal]
# Only available for "topest" domains
name = "Portal customization"
[feature.portal.enable_public_apps_page]
type = "boolean"
@ -67,54 +65,53 @@ name = "Features"
type = "text"
[dns]
name = "DNS"
[dns.registrar]
# This part is automatically generated in DomainConfigPanel
[cert]
name = "Certificate"
[cert.cert]
[cert.cert_]
# The section has a different id than 'cert' otherwise it ends up with an unecessary "name" because it's defined for the panel (in i18n.json)
[cert.cert.cert_summary]
[cert.cert_.cert_summary]
type = "alert"
# Automatically filled by DomainConfigPanel
[cert.cert.cert_validity]
[cert.cert_.cert_validity]
type = "number"
readonly = true
visible = "false"
# Automatically filled by DomainConfigPanel
[cert.cert.cert_issuer]
[cert.cert_.cert_issuer]
type = "string"
visible = false
# Automatically filled by DomainConfigPanel
[cert.cert.acme_eligible]
[cert.cert_.acme_eligible]
type = "boolean"
visible = false
# Automatically filled by DomainConfigPanel
[cert.cert.acme_eligible_explain]
[cert.cert_.acme_eligible_explain]
type = "alert"
style = "warning"
visible = "acme_eligible == false || acme_eligible == null"
[cert.cert.cert_no_checks]
[cert.cert_.cert_no_checks]
type = "boolean"
default = false
visible = "acme_eligible == false || acme_eligible == null"
[cert.cert.cert_install]
[cert.cert_.cert_install]
type = "button"
icon = "star"
style = "success"
visible = "cert_issuer != 'letsencrypt'"
enabled = "acme_eligible || cert_no_checks"
[cert.cert.cert_renew]
[cert.cert_.cert_renew]
type = "button"
icon = "refresh"
style = "warning"

View file

@ -2,9 +2,7 @@ version = "1.0"
i18n = "global_settings_setting"
[security]
name = "Security"
[security.password]
name = "Passwords"
[security.password.admin_strength]
type = "select"
@ -28,7 +26,7 @@ name = "Security"
default = false
[security.ssh]
name = "SSH"
[security.ssh.ssh_compatibility]
type = "select"
choices.intermediate = "Intermediate (compatible with older softwares)"
@ -44,7 +42,6 @@ name = "Security"
default = true
[security.nginx]
name = "NGINX (web server)"
[security.nginx.nginx_redirect_to_https]
type = "boolean"
default = true
@ -56,7 +53,7 @@ name = "Security"
default = "intermediate"
[security.postfix]
name = "Postfix (SMTP email server)"
[security.postfix.postfix_compatibility]
type = "select"
choices.intermediate = "Intermediate (allows TLS 1.2)"
@ -64,7 +61,6 @@ name = "Security"
default = "intermediate"
[security.webadmin]
name = "Webadmin"
[security.webadmin.webadmin_allowlist_enabled]
type = "boolean"
default = false
@ -76,8 +72,6 @@ name = "Security"
default = ""
[security.root_access]
name = "Change root password"
[security.root_access.root_access_explain]
type = "alert"
style = "info"
@ -94,22 +88,17 @@ name = "Security"
default = ""
[security.experimental]
name = "Experimental"
[security.experimental.security_experimental_enabled]
type = "boolean"
default = false
[email]
name = "Email"
[email.pop3]
name = "POP3"
[email.pop3.pop3_enabled]
type = "boolean"
default = false
[email.smtp]
name = "SMTP"
[email.smtp.smtp_allow_ipv6]
type = "boolean"
default = true
@ -143,16 +132,13 @@ name = "Email"
help = "" # This is empty string on purpose, otherwise the core automatically set the 'good_practice_admin_password' string here which is not relevant, because the admin is not actually "choosing" the password ...
[misc]
name = "Other"
[misc.backup]
name = "Backup"
[misc.backup.backup_compress_tar_archives]
type = "boolean"
default = false
[misc.network]
name = "Network"
[misc.network.dns_exposure]
type = "select"
choices.both = "Both"

View file

@ -709,14 +709,14 @@ def _get_DomainConfigPanel():
self.entity
]
raw_config["cert"]["cert"]["cert_summary"]["style"] = status["style"]
raw_config["cert"]["cert_"]["cert_summary"]["style"] = status["style"]
# i18n: domain_config_cert_summary_expired
# i18n: domain_config_cert_summary_selfsigned
# i18n: domain_config_cert_summary_abouttoexpire
# i18n: domain_config_cert_summary_ok
# i18n: domain_config_cert_summary_letsencrypt
raw_config["cert"]["cert"]["cert_summary"]["ask"] = m18n.n(
raw_config["cert"]["cert_"]["cert_summary"]["ask"] = m18n.n(
f"domain_config_cert_summary_{status['summary']}"
)
@ -727,7 +727,7 @@ def _get_DomainConfigPanel():
# FIXME not sure why "summary" was injected in settings values
# ("summary", "summary")
]:
raw_config["cert"]["cert"][option_id]["default"] = status[
raw_config["cert"]["cert_"][option_id]["default"] = status[
status_key
]
@ -850,9 +850,9 @@ def _get_DomainConfigPanel():
def domain_action_run(domain, action, args=None):
import urllib.parse
if action == "cert.cert.cert_install":
if action == "cert.cert_.cert_install":
from yunohost.certificate import certificate_install as action_func
elif action == "cert.cert.cert_renew":
elif action == "cert.cert_.cert_renew":
from yunohost.certificate import certificate_renew as action_func
args = dict(urllib.parse.parse_qsl(args or "", keep_blank_values=True))

View file

@ -84,8 +84,8 @@ class ContainerModel(BaseModel):
value = getattr(self, key)
if value:
setattr(self, key, _value_for_locale(value))
elif key == "help" and m18n.key_exists(f"{i18n_key}_{self.id}_help"):
setattr(self, key, m18n.n(f"{i18n_key}_{self.id}_help"))
elif m18n.key_exists(f"{i18n_key}_{self.id}_{key}"):
setattr(self, key, m18n.n(f"{i18n_key}_{self.id}_{key}"))
class SectionModel(ContainerModel, OptionsModel):