fix: localize empty important package lists

This commit is contained in:
VAIO73
2026-09-17 13:17:08 +02:00
parent 661b944e0c
commit 82c3a49f4c
3 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -3517,7 +3517,9 @@ class PollingCollector:
'security_count': str(len(security_pkgs)),
'pve_count': str(len(pve_pkgs)),
'kernel_count': str(len(kernel_pkgs)),
'important_list': '\n'.join(f' \u2022 {l}' for l in important_lines) if important_lines else 'none',
# An empty value is intentionally rendered later by the
# notification template as the selected locale's “none”.
'important_list': '\n'.join(f' \u2022 {l}' for l in important_lines),
'package_list': ', '.join(important_lines[:6]) if important_lines else '',
}
+2 -1
View File
@@ -1831,7 +1831,8 @@ def render_template(event_type: str, data: Dict[str, Any],
variables[f'{_byte_key}_human'] = _format_bytes_human(data[_byte_key])
# Ensure important_list is never blank (fallback to localized "none")
if not variables.get('important_list', '').strip():
important_list = str(variables.get('important_list', '')).strip()
if not important_list or important_list.casefold() == 'none':
variables['important_list'] = runtime_message('fallback.none', language)
# Derive the affected object's display name for titles that use it.
@@ -189,6 +189,8 @@ class RuntimeCatalogTests(unittest.TestCase):
self.assertIn("🛡️ Bezpečnostné aktualizácie: 0", enriched_body)
self.assertIn("⚙️ Aktualizácie jadra: 0", enriched_body)
self.assertIn("📋 Dôležité balíky:", enriched_body)
self.assertIn("žiadne", enriched_body)
self.assertNotIn("\nnone", enriched_body)
for language in self.RUNTIME_LANGUAGES:
locale_data = {**data, "_notification_language": language}