update
Some checks failed
deploy / deploy (push) Has been cancelled

This commit is contained in:
toom1996
2026-08-18 20:33:56 +08:00
parent c592b9a473
commit d14dd7e2db
13 changed files with 1175 additions and 187 deletions

View File

@ -1,7 +1,7 @@
# 2026-08-16
## i18n 取语言方式重构
- 项目 i18n 已配置(defaultLocale: 'en', locales: ['en','cn'], prefixDefaultLocale: false)。
- 项目 i18n 已配置(defaultLocale: 'en', locales: ['en','cn'])。**注意:本文件撰写时误记 prefixDefaultLocale 为 false;当前 astro.config.mjs 实际为 `prefixDefaultLocale: true`(见 2026-08-18 记忆)。**
- 将 `.astro` 页面里 `getLocaleFromUrl(Astro.url)` 改为 `Astro.currentLocale`(Astro 路由解析,更稳健),并补类型兜底 `(Astro.currentLocale as Locale) ?? DEFAULT_LOCALE`。
- 涉及文件:src/layouts/Layout.astro、src/pages/index.astro、src/pages/cn/index.astro。
- src/i18n/utils.ts 的 `getLocaleFromUrl` 纯函数保留(供 .ts 模块或解析任意 URL 使用)。