mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ migrate user-facing text to i18n (#581)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import cast
|
||||
|
||||
from ..i18n.model import Lang
|
||||
from ..i18n import Lang
|
||||
from .typedefs import Lang as LangType
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ from typing import Any, ParamSpec, TypeVar
|
||||
from nonebot.log import logger
|
||||
from nonebot_plugin_alconna.uniseg import SerializeFailed, UniMessage
|
||||
|
||||
from ..i18n import Lang
|
||||
|
||||
T = TypeVar('T')
|
||||
P = ParamSpec('P')
|
||||
|
||||
@@ -23,7 +25,7 @@ def retry(
|
||||
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
|
||||
for i in range(max_attempts + 1):
|
||||
if i > 0:
|
||||
message = f'Retrying: {func.__name__} ({i}/{max_attempts})'
|
||||
message = Lang.retry.message(func=func.__name__, i=i, max_attempts=max_attempts)
|
||||
logger.debug(message)
|
||||
with suppress(SerializeFailed):
|
||||
await UniMessage(reply or message).send()
|
||||
|
||||
@@ -14,6 +14,7 @@ from nonebot_plugin_alconna import Alconna, Args, Option, on_alconna
|
||||
from rich.progress import Progress
|
||||
|
||||
from ..config.config import CACHE_PATH, DATA_PATH, config
|
||||
from ..i18n import Lang
|
||||
|
||||
driver = get_driver()
|
||||
|
||||
@@ -115,11 +116,11 @@ async def check_tag(tag: str) -> bool:
|
||||
@alc.handle()
|
||||
async def _(revision: str | None = None):
|
||||
if revision is not None and not await check_tag(revision):
|
||||
await alc.finish(f'{revision} 不是模板仓库中的有效标签')
|
||||
await alc.finish(Lang.template_ui.invalid_tag(revision=revision))
|
||||
logger.info('开始更新模板')
|
||||
if await init_templates(revision or 'latest'):
|
||||
await alc.finish('更新模板成功')
|
||||
await alc.finish('更新模板失败')
|
||||
await alc.finish(Lang.template_ui.update_success())
|
||||
await alc.finish(Lang.template_ui.update_failed())
|
||||
|
||||
|
||||
if config.tetris.dev.enable_template_check:
|
||||
|
||||
Reference in New Issue
Block a user