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 • 7 comments

描述

v4.16.0访问会出现i18n选择了中文,这个是英文的情况

Image

以下是代码错误的位置

    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

使用场景

No response

你愿意提交PR吗?

  • [x] 是的, 我愿意提交PR!

Code of Conduct

  • [x] 我已阅读并同意遵守该项目的 行为准则。

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

不对,这个是bug

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

Image 这个地方的文件名称错误了,所以i18n选择中文,这个地方也会出现英文

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

这个一开始是一个增强的iss来着 但是发现是代码问题就改为了bug 所以这个iss可能格式有点不对

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

语言切换功能(LanguageSwitcher)已经在 AstrBot v4.16.0 之后的版本中实现了。现在你可以在新版的 AstrBot 的顶部栏、登录页和聊天界面直接切换中英文,切换后界面会即时生效,并且会自动记住你的选择,下次打开依然生效。支持的语言包括简体中文(zh-CN)和英文(en-US)详情见 PR #1822。

如果你希望使用这个功能,需要升级到包含该特性的新版 AstrBot(v4.16.0 之后)。

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about AstrBot Share Dosu with your team

dosubot[bot] avatar Feb 13 '26 02:02 dosubot[bot]

首次提示出来的时候后面是灰的,应该是切换不了语言的吧

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

是的,首次提示弹窗是一个阻断型(modal)对话框,弹出时会把背景变灰,无法操作主界面,包括语言切换器。只有关闭首次提示后,才能切换语言。这个行为在新版 AstrBot 也是如此设计的。如果希望首次提示内也能切换语言,需要在弹窗内单独加一个语言切换入口,目前默认是无法切换的。参考实现细节。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about AstrBot with Dosu Add Dosu to your team

dosubot[bot] avatar Feb 13 '26 02:02 dosubot[bot]

我干脆重新提交一个算了!

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