Adapt script for missing i18n key following the change in setting nomenclature

This commit is contained in:
Alexandre Aubin 2022-08-05 14:09:14 +02:00
parent 73ed031661
commit fded695b45
3 changed files with 22 additions and 13 deletions

View file

@ -402,8 +402,6 @@
"global_settings_setting_webadmin_allowlist_help": "IP adresses allowed to access the webadmin.",
"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_unknown_setting_from_settings_file": "Unknown key in settings: '{setting_key}', discard it and save it in /etc/yunohost/settings-unknown.json",
"global_settings_unknown_type": "Unexpected situation, the setting {setting} appears to have the type {unknown_type} but it is not a type supported by the system.",
"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",
@ -516,6 +514,7 @@
"migration_description_0021_migrate_to_bullseye": "Upgrade the system to Debian Bullseye and YunoHost 11.x",
"migration_description_0022_php73_to_php74_pools": "Migrate php7.3-fpm 'pool' conf files to php7.4",
"migration_description_0023_postgresql_11_to_13": "Migrate databases from PostgreSQL 11 to 13",
"migration_description_0024_global_settings_to_configpanel": "Migrate legacy global settings nomenclature to the new, modern nomenclature",
"migration_ldap_backup_before_migration": "Creating a backup of LDAP database and apps settings prior to the actual migration.",
"migration_ldap_can_not_backup_before_migration": "The backup of the system could not be completed before the migration failed. Error: {error}",
"migration_ldap_migration_failed_trying_to_rollback": "Could not migrate... trying to roll back the system.",
@ -696,4 +695,4 @@
"yunohost_installing": "Installing YunoHost...",
"yunohost_not_installed": "YunoHost is not correctly installed. Please run 'yunohost tools postinstall'",
"yunohost_postinstall_end_tip": "The post-install completed! To finalize your setup, please consider:\n - adding a first user through the 'Users' section of the webadmin (or 'yunohost user create <username>' in command-line);\n - diagnose potential issues through the 'Diagnosis' section of the webadmin (or 'yunohost diagnosis run' in command-line);\n - reading the 'Finalizing your setup' and 'Getting to know YunoHost' parts in the admin documentation: https://yunohost.org/admindoc."
}
}

View file

@ -99,15 +99,6 @@ def find_expected_string_keys():
for m in ("log_" + match for match in p4.findall(content)):
yield m
# Global settings descriptions
# Will be on a line like : ("security.ssh.ssh_allow_deprecated_dsa_hostkey", {"type": "bool", ...
p5 = re.compile(r" \(\n*\s*[\"\'](\w[\w\.]+)[\"\'],")
content = open(ROOT + "src/settings.py").read()
for m in (
"global_settings_setting_" + s.replace(".", "_") for s in p5.findall(content)
):
yield m
# Keys for the actionmap ...
for category in yaml.safe_load(open(ROOT + "share/actionsmap.yml")).values():
if "actions" not in category.keys():
@ -143,6 +134,7 @@ def find_expected_string_keys():
for key in registrars[registrar].keys():
yield f"domain_config_{key}"
# Domain config panel
domain_config = toml.load(open(ROOT + "share/config_domain.toml"))
for panel in domain_config.values():
if not isinstance(panel, dict):
@ -155,6 +147,24 @@ def find_expected_string_keys():
continue
yield f"domain_config_{key}"
# Global settings
global_config = toml.load(open(ROOT + "share/config_global.toml"))
# Boring hard-coding because there's no simple other way idk
settings_without_help_key = ["admin_strength", "smtp_relay_host", "smtp_relay_password", "smtp_relay_port", "smtp_relay_user", "ssh_port", "ssowat_panel_overlay_enabled", "user_strength"]
for panel in global_config.values():
if not isinstance(panel, dict):
continue
for section in panel.values():
if not isinstance(section, dict):
continue
for key, values in section.items():
if not isinstance(values, dict):
continue
yield f"global_settings_setting_{key}"
if key not in settings_without_help_key:
yield f"global_settings_setting_{key}_help"
###############################################################################
# Compare keys used and keys defined #

View file

@ -26,7 +26,7 @@ class MyMigration(Migration):
try:
old_settings = read_json(OLD_SETTINGS_PATH)
except Exception as e:
raise YunohostError("global_settings_cant_open_settings", reason=e)
raise YunohostError(f"Can't open setting file : {e}", raw_msg=True)
settings = {
translate_legacy_settings_to_configpanel_settings(k): v["value"]