154 lines
15 KiB
Python
154 lines
15 KiB
Python
"""Shared messages; identifiers and raw command evidence remain language neutral."""
|
||
|
||
MESSAGES = {
|
||
"版本符合 Ubuntu 22.04 最低要求;实机兼容性按已测试环境确认": "Version meets the Ubuntu 22.04 minimum; real system compatibility follows tested environments",
|
||
"支持范围:Ubuntu 22.04 及更新版本。": "Target support: Ubuntu 22.04 and newer.",
|
||
"已通过 ipify 查询出口地址;入站可达性未确认": "Egress address queried via ipify; inbound reachability unconfirmed",
|
||
"sshd -T 读取默认配置;权限不足、配置错误或 SSH 运行目录尚未创建均可能导致失败。结果可能与运行中服务或 Match 条件不同。": "sshd -T reads defaults; permissions, configuration or a missing runtime directory can prevent inspection. Running-service and Match settings may differ.",
|
||
'联网检测 DNS 和 TCP 连接并实时显示结果': 'Run outbound DNS and TCP checks with live output',
|
||
'网络质量检测:会向系统 DNS、Cloudflare 和 Google 发起请求。': 'Network quality checks: requests will be sent to the system DNS resolver, Cloudflare and Google.',
|
||
'正在查询 DNS:example.com ...': 'Checking DNS: example.com ...',
|
||
'DNS 查询成功:{versions},耗时 {ms} ms': 'DNS lookup succeeded: {versions}, {ms} ms',
|
||
'其他': 'other',
|
||
'DNS 查询未成功;原因可能是超时、网络或解析器配置,不能确定唯一原因。': 'DNS lookup did not succeed; timeout, network or resolver configuration may be responsible.',
|
||
'正在测试 {target} TCP {port} ...': 'Testing {target} TCP {port} ...',
|
||
'{target} TCP 连接成功:{ms} ms': '{target} TCP connection succeeded: {ms} ms',
|
||
'{target} TCP 连接未成功;原因尚未确定。': '{target} TCP connection did not succeed; the cause is unknown.',
|
||
'以上结果为本次从此服务器到这些测试目标的连接情况。': 'These results describe this server’s current connection to these targets.',
|
||
'运行本地 NodeQuality 脚本并实时显示输出': 'Run a local NodeQuality script and stream its output',
|
||
'已下载并检查的 NodeQuality 脚本路径': 'Path to a locally downloaded and reviewed NodeQuality script',
|
||
'找不到本地脚本文件': 'Local script file not found',
|
||
'未找到 bash,无法运行脚本': 'bash was not found; cannot run the script',
|
||
'无法启动 NodeQuality 脚本': 'Unable to start the NodeQuality script',
|
||
'即将运行第三方 NodeQuality;其可能下载组件、进行网络及性能测试,并向第三方上传结果。输出可能包含公网 IP。': 'Running third-party NodeQuality; it may download components, run network and performance tests, and upload results to third parties. Output may contain public IP addresses.',
|
||
'CPU 信息': 'CPU information',
|
||
'系统可见逻辑 CPU:{count}': 'Logical CPUs visible to the system: {count}',
|
||
'逻辑 CPU 数量未知': 'Logical CPU count unknown',
|
||
'处理器型号:{model}': 'Processor model: {model}',
|
||
'处理器型号未知': 'Processor model unknown',
|
||
'逻辑 CPU 数不一定等于物理核心数;配额限制可能不同。': 'Logical CPUs may differ from physical cores and CPU quota limits.',
|
||
'内核版本': 'Kernel version',
|
||
'根分区容量': 'Root filesystem capacity',
|
||
'总容量 {total:.1f} GiB,可用 {free:.1f} GiB': 'Total {total:.1f} GiB, available {free:.1f} GiB',
|
||
'这是根文件系统容量,不一定等于 VPS 购买的磁盘总容量。': 'This is the root filesystem capacity, which may differ from the purchased disk capacity.',
|
||
'内存总量': 'Total memory',
|
||
'系统可见 {total:.0f} MiB': 'Visible to the system: {total:.0f} MiB',
|
||
'系统可见内存可能与商家标称或容器限额不同。': 'System-visible memory may differ from the advertised amount or container limits.',
|
||
'服务器信息': 'Server information',
|
||
'体检结果': 'Diagnostic results',
|
||
"仅在终端显示完整 IP;保存的报告仍脱敏": "Show full IP addresses only in terminal output; saved reports remain redacted",
|
||
"终端正在显示完整 IP;保存的报告仍脱敏,分享前请检查内容。": "Full IP addresses are visible in terminal output; saved reports remain redacted. Review before sharing.",
|
||
"向 ipify 发送 HTTPS 请求查询出口 IP(第三方会看到该地址)": "Query egress IP over HTTPS from ipify (the third party will see this address)",
|
||
"已通过 ipify 查询出口地址": "Egress address queried via ipify",
|
||
"出口 IP 查询失败,无法确定公网地址": "Egress IP query failed; the public address is unknown",
|
||
"出口地址可能是 NAT 或代理地址;不是入站可达性证明。": "The egress address may belong to NAT or a proxy; it does not establish inbound reachability.",
|
||
"只读体检 · 已请求 ipify 查询出口 IP": "Read-only checks · ipify egress IP lookup requested",
|
||
"默认路由": "Default route",
|
||
"路由读取失败或格式无法解析": "Route read failed or output could not be parsed",
|
||
"已读取默认路由": "Default route read",
|
||
"默认路由信息不完整或未找到,无法确认网络出口": "Default route information is incomplete or missing; the network exit is unconfirmed",
|
||
"仅检查当前网络命名空间的默认路由,不覆盖策略路由。": "Only the current network namespace's default routes are checked; policy routing is not covered.",
|
||
"DNS 配置": "DNS configuration",
|
||
"无法读取 DNS 配置": "Unable to read DNS configuration",
|
||
"DNS 配置不完整或没有有效的服务器地址": "DNS configuration is incomplete or has no valid server address",
|
||
"DNS 指向本机解析器": "DNS points to a local resolver",
|
||
"已读取 DNS 服务器配置": "DNS server configuration read",
|
||
"仅检查 resolv.conf,不主动发送 DNS 请求;实际解析路径可能不同。": "Only resolv.conf is inspected; no DNS request is sent, and the actual resolution path may differ.",
|
||
"SSH 端口保护": "SSH port protection",
|
||
"sshd 默认配置端口:{ports}": "sshd default configured ports: {ports}",
|
||
"当前 SSH 会话本地端口:{port}": "Current SSH session local port: {port}",
|
||
"目标端口与 SSH 已知端口冲突;不要用于代理": "The target port conflicts with a known SSH port; do not use it for the proxy",
|
||
"未能排除与运行中 SSH 端口冲突": "A conflict with a running SSH port cannot be ruled out",
|
||
"检查运行中 SSH、socket 激活及自定义实例;证据不足时不要进行端口或防火墙修改。": "Check running SSH, socket activation and custom instances; do not change ports or firewall rules when evidence is insufficient.",
|
||
"SSH 端口输出不完整或无效": "SSH port output is incomplete or invalid",
|
||
"输出超过读取上限,不能作为完整检查结果": "Output exceeded the read limit; it cannot be treated as a complete result",
|
||
"无法读取 Linux 发行版标识,不能确认系统要求": "Unable to read the Linux distribution ID; system requirements are unconfirmed",
|
||
"SSH 输出缺少关键字段,无法完成风险判断": "SSH output is missing required fields; risk assessment is incomplete",
|
||
"sing-box 服务处于 failed 状态,需要检查启动失败原因": "sing-box service is in the failed state; investigate the startup failure",
|
||
"sing-box 开机启动": "sing-box startup at boot",
|
||
"已配置持久开机启动": "Persistent startup at boot is enabled",
|
||
"未配置持久开机启动或服务被屏蔽,重启后可能不可用": "Persistent startup is not enabled or the service is masked; it may be unavailable after reboot",
|
||
"无法确认 sing-box 的持久开机启动状态": "Persistent sing-box startup at boot is unconfirmed",
|
||
"命令不可用": "Command unavailable",
|
||
"命令返回非零状态,可能需要读取权限": "Command returned a nonzero status; read permissions may be required",
|
||
"读取命令失败,可能是权限、配置或服务状态问题": "Read command failed; permissions, configuration or service state may be responsible",
|
||
"sshd -T 读取默认配置;权限不足、配置错误或 SSH 运行目录尚未创建均可能导致失败。结果可能与运行中服务或 Match 条件不同;不自动修改 SSH。": "sshd -T reads default configuration; it can fail due to permissions, configuration errors or a missing SSH runtime directory. Results may differ from the running service or Match conditions; SSH is not modified.",
|
||
"读取超时(8 秒)": "Read timed out (8 seconds)",
|
||
"无法执行读取命令": "Unable to execute read command",
|
||
"操作系统": "Operating system",
|
||
"版本符合 Ubuntu 22.04 最低要求": "Version meets the Ubuntu 22.04 minimum",
|
||
"无法解析 Ubuntu 版本,不能确认是否符合最低要求": "Unable to parse the Ubuntu version; minimum requirement is unconfirmed",
|
||
"需要 Ubuntu 22.04 或更新版本": "Ubuntu 22.04 or newer is required",
|
||
"版本未知": "Version unknown",
|
||
"其他系统的结果仅供参考。": "Results on other systems are informational.",
|
||
"版本检查 Ubuntu 22.04 及更新版本受支持。": "Ubuntu 22.04 and newer versions are supported.",
|
||
"系统架构": "Architecture",
|
||
"检测架构;本阶段不验证安装包兼容性": "Architecture detected; package compatibility is not checked at this stage",
|
||
"根分区可用空间": "Free space on root filesystem",
|
||
"可用 {free:.1f} GiB(体检提示阈值 1 GiB)": "{free:.1f} GiB free (advisory threshold: 1 GiB)",
|
||
"无法读取": "Unable to read",
|
||
"公网 IP": "Public IP",
|
||
"用户提供的地址具备公网地址属性": "The supplied address is globally routable",
|
||
"提供的地址不是全局可路由公网地址": "The supplied address is not a globally routable public address",
|
||
"默认不向第三方查询出口 IP": "No third-party egress IP lookup is performed by default",
|
||
"可用 --public-ip 填写云控制台地址;地址归属及入站可达性仍需外部验证。": "Use --public-ip to supply the address from your cloud console; ownership and inbound reachability still need external verification.",
|
||
"云防火墙与外部可达性": "Cloud firewall and external reachability",
|
||
"本机读取不能确认云安全组、NAT 或外部网络路径": "Local reads cannot verify cloud security groups, NAT or external network paths",
|
||
"后续从客户端独立测试;不能仅据此认定端口已开放或被封锁。": "Test independently from a client; this result alone cannot establish whether a port is reachable or blocked.",
|
||
"内存": "Memory", "网络地址": "Network addresses", "端口占用": "Port usage",
|
||
"SSH 配置": "SSH configuration", "本机防火墙": "Local firewall", "sing-box 服务": "sing-box service",
|
||
"此项需要 Linux;当前主机仅验证程序运行": "Requires Linux; this host only validates that the program runs",
|
||
"可用内存": "Available memory",
|
||
"约 {mib:.0f} MiB(体检提示阈值 256 MiB)": "About {mib:.0f} MiB (advisory threshold: 256 MiB)",
|
||
"无法读取 MemAvailable": "Unable to read MemAvailable",
|
||
"仅表示本机接口地址": "Local interface addresses only",
|
||
"无法解析接口信息": "Unable to parse interface information",
|
||
"目标端口占用": "Target port usage",
|
||
"目标 TCP/UDP 端口 {port} 已有监听": "A listener already uses target TCP/UDP port {port}",
|
||
"无法完整确认端口占用": "Unable to fully determine port usage",
|
||
"当前未发现 TCP/UDP 端口 {port} 的监听": "No listener currently found on TCP/UDP port {port}",
|
||
"选择未占用端口;不会停止已有服务。": "Choose an unused port; existing services will not be stopped.",
|
||
"允许 root 登录或密码认证": "Root login or password authentication is allowed",
|
||
"未发现这两项宽松设置": "Neither of these permissive settings was found",
|
||
"sshd -T 读取默认配置,可能与运行中服务或 Match 条件一致。": "sshd -T reads default configuration, which may differ from the running service or Match conditions.",
|
||
"读取失败": "Read failed", "已读取;": "Read completed; ",
|
||
"存在状态或规则信息": "state or rule information exists",
|
||
"未发现活动状态或规则": "no active state or rules found",
|
||
"发现防火墙状态或规则;未判断规则是否允许目标端口": "Firewall state or rules found; permission for the target port is not evaluated",
|
||
"没有足够证据确认防火墙保护状态": "Insufficient evidence to establish firewall protection",
|
||
"部分工具不可用或权限不足。": "Some tools are unavailable or permissions are insufficient.",
|
||
"规则存在不等于配置安全。": "The presence of rules does not establish a secure configuration.",
|
||
"服务处于 active": "Service is active",
|
||
"未确认 sing-box 服务运行;新系统尚未安装属于正常情况": "sing-box service operation is unconfirmed; absence is expected on a fresh system",
|
||
"通过": "PASS", "注意": "WARN", "未知": "UNKNOWN", "跳过": "SKIP", "失败": "FAIL",
|
||
"[IP已隐藏]": "[IP REDACTED]",
|
||
"VPS 检测工具 只读体检:不修改系统;默认不请求外部网络": "VPSMaster read-only checks: no system changes; no external requests by default",
|
||
"读取系统信息并生成体检报告": "Read system information and generate a diagnostic report",
|
||
"拟使用的代理端口,默认 8388": "Intended proxy port (default: 8388)",
|
||
"云控制台提供的 IP;本工具不验证归属": "IP from your cloud console; ownership is not verified",
|
||
"输出 JSON(默认隐藏 IP)": "Print JSON (IP addresses are redacted by default)",
|
||
"另存为脱敏 JSON;已存在的文件不会覆盖": "Save redacted JSON; existing files are never overwritten",
|
||
"界面和报告语言:zh 中文,en 英文(默认 zh)": "Interface and report language: zh Chinese, en English (default: zh)",
|
||
"端口必须在 1~65535 之间": "Port must be between 1 and 65535",
|
||
"--public-ip 必须是有效 IPv4 或 IPv6 地址": "--public-ip must be a valid IPv4 or IPv6 address",
|
||
"无法保存报告:{error}": "Unable to save report: {error}",
|
||
"只读体检 · 默认不请求外部网络": "Read-only checks · No external requests by default",
|
||
"依据": "Evidence",
|
||
"报告默认隐藏 IP。": "IP addresses are redacted by default.",
|
||
"参数错误:{message}": "Argument error: {message}",
|
||
"显示帮助并退出": "Show this help message and exit",
|
||
"显示版本并退出": "Show version and exit",
|
||
"命令": "Commands", "选项": "Options",
|
||
}
|
||
|
||
|
||
def translator(lang):
|
||
if lang not in {"zh", "en"}:
|
||
raise ValueError("Unsupported language; choose zh or en")
|
||
|
||
def translate(key, **values):
|
||
text = MESSAGES.get(key, key) if lang == "en" else key
|
||
return text.format(**values) if values else text
|
||
|
||
return translate
|