进一步的 kvmd 国际化(汉化)支持,添加配置入口

yaml 配置示例:
```
languages:
    console: zh
    web: zh
```
This commit is contained in:
mofeng-git
2024-08-14 22:54:12 +08:00
parent 5b25b3661f
commit 35397c5414
47 changed files with 567 additions and 181 deletions

View File

@@ -25,7 +25,7 @@ from typing import AsyncGenerator
from ...errors import OperationError
from ...errors import IsBusyError
from ...lanuages import Lanuages
from ...languages import Languages
from .. import BasePlugin
from .. import get_plugin_class
@@ -42,7 +42,7 @@ class AtxOperationError(OperationError, AtxError):
class AtxIsBusyError(IsBusyError, AtxError):
def __init__(self) -> None:
super().__init__(Lanuages().gettext("Performing another ATX operation, please try again later"))
super().__init__(Languages().gettext("Performing another ATX operation, please try again later"))
# =====

View File

@@ -39,7 +39,7 @@ from ...validators.basic import valid_float_f01
from ...validators.os import valid_abs_path
from ...validators.hw import valid_gpio_pin
from ...lanuages import Lanuages
from ...languages import Languages
from . import AtxIsBusyError
from . import BaseAtx
@@ -193,7 +193,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
await self.__inner_click(name, pin, delay)
else:
await aiotools.run_region_task(
Lanuages().gettext(f"Can't perform ATX {name} click or operation was not completed"),
Languages().gettext(f"Can't perform ATX {name} click or operation was not completed"),
self.__region, self.__inner_click, name, pin, delay,
)
@@ -206,4 +206,4 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
finally:
self.__line_request.set_value(pin, gpiod.line.Value(False))
await asyncio.sleep(1)
get_logger(0).info(Lanuages().gettext("Clicked ATX button %r"), name)
get_logger(0).info(Languages().gettext("Clicked ATX button %r"), name)