Skip to content

Commit 499b548

Browse files
committed
translations: replace invalid format key names with "{unknown_key}"
1 parent 0a82762 commit 499b548

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tagstudio/src/qt/translations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
from collections import defaultdict
12
from pathlib import Path
3+
from typing import Any
24

35
import structlog
46
import ujson
@@ -37,7 +39,9 @@ def __format(self, text: str, **kwargs) -> str:
3739
kwargs=kwargs,
3840
language=self._lang,
3941
)
40-
return text
42+
params: defaultdict[str, Any] = defaultdict(lambda: "{unknown_key}")
43+
params.update(kwargs)
44+
return text.format_map(params)
4145

4246
def format(self, key: str, **kwargs) -> str:
4347
return self.__format(self[key], **kwargs)

0 commit comments

Comments
 (0)