mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-02 02:51:53 +08:00
初步的 kvmd 国际化(汉化)支持
1. 添加汉化文件 2. 添加 Lanuages().gettext 函数处理字符替换 3. 修改相关字符串调用
This commit is contained in:
@@ -25,6 +25,8 @@ import contextlib
|
||||
|
||||
from typing import Generator
|
||||
|
||||
from ....lanuages import Lanuages
|
||||
|
||||
|
||||
# =====
|
||||
class ChipResponseError(Exception):
|
||||
@@ -35,6 +37,7 @@ class ChipResponseError(Exception):
|
||||
class ChipConnection:
|
||||
def __init__(self, tty: serial.Serial) -> None:
|
||||
self.__tty = tty
|
||||
self.gettext=Lanuages().gettext
|
||||
|
||||
def xfer(self, cmd: bytes) -> int:
|
||||
self.__send(cmd)
|
||||
@@ -52,16 +55,16 @@ class ChipConnection:
|
||||
def __recv(self) -> int:
|
||||
data = self.__tty.read(5)
|
||||
if len(data) < 5:
|
||||
raise ChipResponseError("Too short response, HID might be disconnected")
|
||||
raise ChipResponseError(self.gettext("Too short response, HID might be disconnected"))
|
||||
|
||||
if data and data[4]:
|
||||
data += self.__tty.read(data[4] + 1)
|
||||
|
||||
if self.__make_checksum(data[:-1]) != data[-1]:
|
||||
raise ChipResponseError("Invalid response checksum")
|
||||
raise ChipResponseError(self.gettext("Invalid response checksum"))
|
||||
|
||||
if data[4] == 1 and data[5] != 0:
|
||||
raise ChipResponseError(f"Response error code = {data[5]!r}")
|
||||
raise ChipResponseError(self.gettext(f"Response error code = {data[5]!r}"))
|
||||
|
||||
# led_byte (info) response
|
||||
return (data[7] if data[3] == 0x81 else -1)
|
||||
|
||||
Reference in New Issue
Block a user