From d049928be79c144a001070d3a2408a9ba105911b Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Fri, 9 Feb 2024 08:35:12 +0100 Subject: [PATCH] Log error and continue on parsing issues of translated strings (#110046) --- homeassistant/helpers/translation.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/translation.py b/homeassistant/helpers/translation.py index ab9d5f576fe..be3e0464361 100644 --- a/homeassistant/helpers/translation.py +++ b/homeassistant/helpers/translation.py @@ -273,7 +273,13 @@ class _TranslationCache: for key, value in updated_resources.items(): if key not in cached_resources: continue - tuples = list(string.Formatter().parse(value)) + try: + tuples = list(string.Formatter().parse(value)) + except ValueError: + _LOGGER.error( + ("Error while parsing localized (%s) string %s"), language, key + ) + continue updated_placeholders = {tup[1] for tup in tuples if tup[1] is not None} tuples = list(string.Formatter().parse(cached_resources[key]))