MCPcopy
hub / github.com/kvcache-ai/ktransformers / t

Function t

kt-kernel/python/cli/i18n.py:1306–1333  ·  view source on GitHub ↗

Translate a message key to the current language. Args: msg_key: Message key to translate **kwargs: Format arguments for the message Returns: Translated and formatted message string Example: >>> t("welcome") "Welcome to KTransformers!" # or

(msg_key: str, **kwargs: Any)

Source from the content-addressed store, hash-verified

1304
1305
1306def t(msg_key: str, **kwargs: Any) -> str:
1307 """
1308 Translate a message key to the current language.
1309
1310 Args:
1311 msg_key: Message key to translate
1312 **kwargs: Format arguments for the message
1313
1314 Returns:
1315 Translated and formatted message string
1316
1317 Example:
1318 >>> t("welcome")
1319 "Welcome to KTransformers!" # or "欢迎使用 KTransformers!" in Chinese
1320
1321 >>> t("install_found", name="conda", version="24.1.0")
1322 "Found conda (version 24.1.0)"
1323 """
1324 lang = get_lang()
1325 messages = MESSAGES.get(lang, MESSAGES["en"])
1326 message = messages.get(msg_key, MESSAGES["en"].get(msg_key, msg_key))
1327
1328 if kwargs:
1329 try:
1330 return message.format(**kwargs)
1331 except KeyError:
1332 return message
1333 return message
1334
1335
1336def set_lang(lang: str) -> None:

Callers 15

_show_first_run_setupFunction · 0.90
_prompt_custom_pathFunction · 0.90
print_version_tableFunction · 0.90
print_dependency_tableFunction · 0.90
prompt_choiceFunction · 0.90
print_model_tableFunction · 0.90
print_server_infoFunction · 0.90
print_api_infoFunction · 0.90
check_sglang_and_warnFunction · 0.90
select_model_to_quantizeFunction · 0.90

Calls 2

get_langFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected