mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user