From 45779a6c50b9f6fa1721846445e8781216e4e2a7 Mon Sep 17 00:00:00 2001 From: yusufipk Date: Sat, 1 Aug 2026 20:06:28 +0700 Subject: [PATCH] Say which stock phrase was discarded, instead of crashing on it A transcript the hallucination filter throws away is named in the message that says so, and the placeholder it goes into is called {text}. So is the first parameter of t(), which made the call two values for one argument and a TypeError: the user was told "Unexpected error" rather than what happened. Both strings are positional-only now, so no placeholder can ever collide with them again. --- i18n.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/i18n.py b/i18n.py index 13ec3d2..f2b1a70 100644 --- a/i18n.py +++ b/i18n.py @@ -27,7 +27,10 @@ def language(): return _lang -def t(text, **kwargs): +def t(text, /, **kwargs): + # The string is positional-only so that every name is free to be a + # placeholder: t("Discarded: {text}", text=…) would otherwise be two values + # for one argument, and fail at the moment the message is shown. out = TR.get(text, text) if _lang == "tr" else text return out.format(**kwargs) if kwargs else out @@ -42,7 +45,7 @@ _TR_CASES = { } -def name(text, case=""): +def name(text, /, case=""): if _lang != "tr" or not case: return text return _TR_CASES.get(case, {}).get(text, text)