Skip to content

fix-correct-FIRST_NOTICE.md-locale-path-resolution (#5083)#5082

Merged
Soulter merged 2 commits intoAstrBotDevs:masterfrom
Li-shi-ling:fix--correct-FIRST_NOTICE.md-locale-path-resolution
Feb 13, 2026
Merged

fix-correct-FIRST_NOTICE.md-locale-path-resolution (#5083)#5082
Soulter merged 2 commits intoAstrBotDevs:masterfrom
Li-shi-ling:fix--correct-FIRST_NOTICE.md-locale-path-resolution

Conversation

@Li-shi-ling
Copy link
Contributor

@Li-shi-ling Li-shi-ling commented Feb 13, 2026

修理的问题是首次页面的文件目录名称问题
v4.16.0访问会出现i18n选择了中文,这个是英文的情况
Fixes #5083

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

Modifications / 改动点

以下是代码错误的位置

    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

549174699-3492c291-767b-4114-9f31-7be435a3b0a5
  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

首次页面出现这个问题我无法进行测试
这个问题是个很简单的更改,这个修改方案应该是有效的


Checklist / 检查清单

  • [ X ] 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 没有新功能
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 首次页面出现这个问题我无法进行测试
  • 这个问题是个很简单的更改,这个修改方案应该是有效的
  • [ X ] 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • [ X ] 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

Bug Fixes:

  • 修正当选择中文区域设置时使用的 FIRST_NOTICE 文件路径,使其指向已有的 FIRST_NOTICE.md 文件,而不是不存在的 zh-CN 变体。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Correct the FIRST_NOTICE file path used when a Chinese locale is selected so that it resolves to the existing FIRST_NOTICE.md file instead of a non-existent zh-CN variant.

@auto-assign auto-assign bot requested review from Raven95676 and anka-afk February 13, 2026 02:15
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 13, 2026
@dosubot
Copy link

dosubot bot commented Feb 13, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些高层面的反馈:

  • 在处理 zh 语言环境时,与其完全替换掉 FIRST_NOTICE.zh-CN.md 这一后备文件,不如考虑在保留 FIRST_NOTICE.zh-CN.md 的同时,额外追加 FIRST_NOTICE.md。这样既能兼容当前的文件名,又能在将来支持 zh-CN 特定的文件。
  • 当前逻辑可能会两次将 FIRST_NOTICE.md 添加到 candidates(一次是在处理 zh 时,另一次是在通用的 extend 中),可以考虑对候选列表去重,或重构追加逻辑,以避免重复的文件系统检查。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- When handling the `zh` locale, instead of replacing the `FIRST_NOTICE.zh-CN.md` fallback entirely, consider appending `FIRST_NOTICE.md` in addition to `FIRST_NOTICE.zh-CN.md` so that future zh-CN-specific files can be supported while still working with the current filename.
- The current logic can add `FIRST_NOTICE.md` to `candidates` twice (once for `zh` and once in the common `extend`), so consider de-duplicating the candidate list or restructuring the appends to avoid redundant filesystem checks.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've left some high level feedback:

  • When handling the zh locale, instead of replacing the FIRST_NOTICE.zh-CN.md fallback entirely, consider appending FIRST_NOTICE.md in addition to FIRST_NOTICE.zh-CN.md so that future zh-CN-specific files can be supported while still working with the current filename.
  • The current logic can add FIRST_NOTICE.md to candidates twice (once for zh and once in the common extend), so consider de-duplicating the candidate list or restructuring the appends to avoid redundant filesystem checks.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When handling the `zh` locale, instead of replacing the `FIRST_NOTICE.zh-CN.md` fallback entirely, consider appending `FIRST_NOTICE.md` in addition to `FIRST_NOTICE.zh-CN.md` so that future zh-CN-specific files can be supported while still working with the current filename.
- The current logic can add `FIRST_NOTICE.md` to `candidates` twice (once for `zh` and once in the common `extend`), so consider de-duplicating the candidate list or restructuring the appends to avoid redundant filesystem checks.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Li-shi-ling Li-shi-ling changed the title fix-correct-FIRST_NOTICE.md-locale-path-resolution fix-correct-FIRST_NOTICE.md-locale-path-resolution (#5080) Feb 13, 2026
@dosubot dosubot bot added the area:core The bug / feature is about astrbot's core, backend label Feb 13, 2026
@Li-shi-ling
Copy link
Contributor Author

Li-shi-ling commented Feb 13, 2026

这个只是对现在的i18n问题做改动
对于进入到首次提醒页面无法切换语言的问题还是存在
我希望在首次提醒页面提交一个按钮可以切换语言

@Li-shi-ling Li-shi-ling changed the title fix-correct-FIRST_NOTICE.md-locale-path-resolution (#5080) fix-correct-FIRST_NOTICE.md-locale-path-resolution (#5083) Feb 13, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 13, 2026
@Soulter Soulter merged commit 935168c into AstrBotDevs:master Feb 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants