mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-06-26 00:11:09 +03:00
i18n fixes
This commit is contained in:
+11
-8
@@ -809,6 +809,16 @@ def merge_adv_from_form(
|
||||
base[key] = default_config[key]
|
||||
|
||||
|
||||
def _dc_validation_message(error: ValueError) -> str:
|
||||
exc_entry = getattr(error, "entry", None)
|
||||
if exc_entry is None:
|
||||
return str(error)
|
||||
kind = getattr(error, "kind", "invalid")
|
||||
if kind == "format":
|
||||
return t("validation.dc_format", entry=exc_entry)
|
||||
return t("validation.dc_invalid", entry=exc_entry)
|
||||
|
||||
|
||||
def validate_config_form(
|
||||
widgets: TrayConfigFormWidgets,
|
||||
default_config: dict,
|
||||
@@ -838,14 +848,7 @@ def validate_config_form(
|
||||
try:
|
||||
parse_dc_ip_list(lines)
|
||||
except ValueError as e:
|
||||
msg = str(e)
|
||||
if "expected DC:IP" in msg:
|
||||
entry = msg.split("format ", 1)[-1].rstrip(")")
|
||||
return t("validation.dc_format", entry=entry.strip("'"))
|
||||
if msg.startswith("Invalid --dc-ip "):
|
||||
entry = msg.split(" ", 2)[-1]
|
||||
return t("validation.dc_invalid", entry=entry)
|
||||
return msg
|
||||
return _dc_validation_message(e)
|
||||
|
||||
secret_val = widgets.secret_var.get().strip()
|
||||
if len(secret_val) != 32:
|
||||
|
||||
+4
-3
@@ -26,7 +26,7 @@ class LocaleEnum(str, Enum):
|
||||
|
||||
|
||||
_LOCALES_DIR = Path(__file__).resolve().parent
|
||||
_DEFAULT_LOCALE = LocaleEnum.russian
|
||||
_DEFAULT_LOCALE = LocaleEnum.english
|
||||
|
||||
_translations: Dict[str, str] = {}
|
||||
_current_lang: LocaleEnum = _DEFAULT_LOCALE
|
||||
@@ -137,10 +137,11 @@ def language_option_labels() -> List[Tuple[LocaleEnum, str]]:
|
||||
|
||||
def language_label_for_config(value: LocaleInput) -> str:
|
||||
loc = LocaleEnum.parse(value)
|
||||
for cfg_val, label in language_option_labels():
|
||||
labels = language_option_labels()
|
||||
for cfg_val, label in labels:
|
||||
if cfg_val == loc:
|
||||
return label
|
||||
return language_option_labels()[0][1]
|
||||
return labels[0][1] if labels else _DEFAULT_LOCALE.value
|
||||
|
||||
|
||||
def refresh_language_option_maps() -> None:
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
"connectivity.cfproxy_title": "CF Proxy",
|
||||
"connectivity.cfworker_title": "CF Worker",
|
||||
"connectivity.timeout": "timeout",
|
||||
"connectivity.no_response": "no response",
|
||||
"connectivity.available": "{title}: available",
|
||||
"connectivity.unavailable": "{title}: unavailable",
|
||||
"connectivity.all_ok": "{title}: all working",
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
"connectivity.cfproxy_title": "CF-прокси",
|
||||
"connectivity.cfworker_title": "CF Worker",
|
||||
"connectivity.timeout": "таймаут",
|
||||
"connectivity.no_response": "нет ответа",
|
||||
"connectivity.available": "{title}: доступен",
|
||||
"connectivity.unavailable": "{title}: недоступен",
|
||||
"connectivity.all_ok": "{title}: всё работает",
|
||||
|
||||
Reference in New Issue
Block a user