AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[bug] v4.16.0首次提示页面中i18n选择为中文,但是首次提示显示为英文

Open Li-shi-ling opened this issue 9 months ago • 0 comments

What happened / 发生了什么

在首次提醒页面,现在的i18n为中文,但是出现的首次提醒为英文

549167127-b5a92c1b-88bd-4a62-91c1-41d0906a564c

以下是代码错误的位置

    async def get_first_notice(self):
        """读取项目根目录 FIRST_NOTICE.md 内容。"""
        try:
            locale = (request.args.get("locale") or "").strip()
            if not re.match(r"^[A-Za-z0-9_-]*$", locale):
                locale = ""

            base_path = Path(get_astrbot_path())
            candidates: list[Path] = []

            if locale:
                candidates.append(base_path / f"FIRST_NOTICE.{locale}.md")
                if locale.lower().startswith("zh"):
                    candidates.append(base_path / "FIRST_NOTICE.zh-CN.md")
                elif locale.lower().startswith("en"):
                    candidates.append(base_path / "FIRST_NOTICE.en-US.md")

            candidates.extend(
                [
                    base_path / "FIRST_NOTICE.en-US.md",
                    base_path / "FIRST_NOTICE.md",
                ],
            )

            for notice_path in candidates:
                if not notice_path.is_file():
                    continue
                content = notice_path.read_text(encoding="utf-8")
                if content.strip():
                    return Response().ok({"content": content}).__dict__

            return Response().ok({"content": None}).__dict__
        except Exception as e:
            logger.error(traceback.format_exc())
            return Response().error(f"Error: {e!s}").__dict__

其中

                if locale.lower().startswith("zh"):
                    candidates.append(base_path / "FIRST_NOTICE.zh-CN.md")

的名称错误了,在文件中为FIRST_NOTICE.md

Reproduce / 如何复现?

安装4.16.0版本的astrbot并且打开wenui

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

ubt22.04lts astrbot4.16.0

OS

Linux

Logs / 报错日志

这个是前端的问题,没有日志

549167127-b5a92c1b-88bd-4a62-91c1-41d0906a564c

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [x] Yes!

Code of Conduct

Li-shi-ling avatar Feb 13 '26 02:02 Li-shi-ling