From c5491e27b616a9d676cd33aa750c68a9456d660d Mon Sep 17 00:00:00 2001
From: idleRain
Date: Wed, 14 Oct 2026 17:02:45 +0800
Subject: [PATCH 1/7] =?UTF-8?q?fix(web):=20=E9=94=99=E8=AF=AF=E9=A1=B5?=
=?UTF-8?q?=E6=8C=89=E7=8A=B6=E6=80=81=E7=A0=81=E5=88=86=E6=A1=A3=EF=BC=8C?=
=?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5=E4=B8=8D=E5=86=8D=E8=AF=AF?=
=?UTF-8?q?=E6=8A=A5=E4=B8=BA=E8=B5=84=E6=BA=90=E7=BC=BA=E5=A4=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
错误页原先仅将 500 判定为服务端故障,而各路由的加载失败以 503 冒泡到错误页,落入资源缺失分档,用户看到「这一页翻不到」且缺少重试入口。
分档下限改为按 5xx 判定,与各路由 +page.ts 与 +page.server.ts 抛出的 503 对齐。
---
apps/web/src/routes/+error.svelte | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/apps/web/src/routes/+error.svelte b/apps/web/src/routes/+error.svelte
index b7db781..dcb3e53 100644
--- a/apps/web/src/routes/+error.svelte
+++ b/apps/web/src/routes/+error.svelte
@@ -9,8 +9,10 @@ import '../app.css'
const status = $derived(page.status)
const error = $derived(page.error)
-// 依据状态码区分文案,500 为服务端故障,其余视为目标资源缺失。
-const isServerError = $derived(status === 500)
+// 错误页按状态码分档:5xx 为服务端故障,提供重试入口并展示具体消息;其余状态码视为目标资源缺失,仅保留返回入口。
+// 数据加载失败以 503 冒泡到错误页,故分档下限取 500 而非仅匹配 500 本身。
+const SERVER_ERROR_STATUS_MIN = 500
+const isServerError = $derived(status >= SERVER_ERROR_STATUS_MIN)
const errorTitle = $derived(
isServerError ? m['ui:error.serverErrorTitle']() : m['ui:error.notFoundTitle']()
)
From 2d16c251bac8e417779705d13ef1f1cbb4a5b4a8 Mon Sep 17 00:00:00 2001
From: idleRain
Date: Wed, 14 Oct 2026 17:20:56 +0800
Subject: [PATCH 2/7] =?UTF-8?q?feat(i18n):=20=E9=A6=96=E9=A1=B5=E6=95=B4?=
=?UTF-8?q?=E9=9D=A2=E4=B8=8E=E5=85=B1=E4=BA=AB=E8=AF=8D=E6=8E=A5=E5=85=A5?=
=?UTF-8?q?=E8=AF=8D=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
首页 SEO、首屏、目录、侧边栏与年轮预览文案改经词表取词,含加载失败文案。
词表按面新建 home namespace,并在 project.inlang/settings.json 注册。
站名与作者身份收敛为 ui 共享词条,Header 同步改用它们,页面标题不再引用中文站名常量。
词表目录写入 .prettierignore:prettier 会改写为无引号键,paraglide 按严格 JSON 解析将编译失败。
债务登记同步:frontend 第 7 条更新基线与词表约定;新增 architecture 第 8 条,并登记第 8 节索引与第 9 节阶段八。
---
.prettierignore | 3 +
apps/web/messages/en/home.json5 | 58 +++++++
apps/web/messages/en/ui.json5 | 19 ++-
apps/web/messages/zh/home.json5 | 58 +++++++
apps/web/messages/zh/ui.json5 | 19 ++-
apps/web/project.inlang/settings.json | 3 +-
.../src/lib/components/home/BackToTop.svelte | 3 +-
.../lib/components/home/FeaturedStory.svelte | 12 +-
.../lib/components/home/HeroSection.svelte | 39 +++--
.../components/home/PostIndexSection.svelte | 43 +++---
.../src/lib/components/layout/Header.svelte | 6 +-
apps/web/src/routes/(app)/+page.svelte | 27 ++--
apps/web/src/routes/(app)/+page.ts | 3 +-
docs/architecture-rules.md | 145 +++++++++---------
docs/debt/README.md | 12 +-
docs/debt/architecture.md | 7 +
docs/debt/frontend.md | 7 +-
docs/development.md | 91 ++++++-----
18 files changed, 368 insertions(+), 187 deletions(-)
create mode 100644 apps/web/messages/en/home.json5
create mode 100644 apps/web/messages/zh/home.json5
diff --git a/.prettierignore b/.prettierignore
index 9a95d64..0da0503 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -14,3 +14,6 @@ yarn.lock
packages/ui/
.eslintrc-auto-import.js
auto-imports.d.ts
+
+# 词表文件经 paraglide 按严格 JSON 解析,prettier 的 json5 解析器会改写为无引号键与单引号串,导致编译失败
+apps/web/messages/
diff --git a/apps/web/messages/en/home.json5 b/apps/web/messages/en/home.json5
new file mode 100644
index 0000000..71043cd
--- /dev/null
+++ b/apps/web/messages/en/home.json5
@@ -0,0 +1,58 @@
+{
+ "seo": {
+ "title": "{{site}} - Compiling ideas into interfaces",
+ "description": "A personal blog on engineering practice and creative design, exploring what modern web development makes possible.",
+ "descriptionShort": "A personal blog on engineering practice and creative design",
+ "keywords": "blog,technology,development,design,SvelteKit,Go,full-stack development"
+ },
+ "hero": {
+ "eyebrow": "Journal · Code & Life",
+ "headlineLead": "Compiling ideas",
+ "headlineTail": "into ",
+ "headlineAccent": "interfaces",
+ "headlineNote": "// engineering × design",
+ "intro": "Notes on engineering practice, city wanderings, and the books finished late at night. I believe in slow and solid accumulation, and favour clean structures and honest writing.",
+ "ctaRead": "Start reading",
+ "excerptLabel": "This month's excerpt",
+ "quote": "“Write down what you have thought through, then do what you have written down.”",
+ "quoteAuthor": "— founding editor's note",
+ "specEngineering": "01 / Engineering",
+ "specDesign": "02 / Design",
+ "specLife": "03 / Life",
+ "imprint": "{{site}} — EST. 2026",
+ "scrollHint": "Scroll"
+ },
+ "index": {
+ "title": "Recent posts",
+ "count_one": "{{count}} post · continuously updated",
+ "count_other": "{{count}} posts · continuously updated",
+ "emptyTitle": "The inaugural issue is in preparation, posts will follow soon.",
+ "emptyNote": "You can browse the layout and the site introduction in the meantime, or wait for updates on the archive page.",
+ "viewAll": "View all posts"
+ },
+ "featured": {
+ "badge": "Featured",
+ "categoryFallback": "Journal",
+ "readMore": "Read the full post"
+ },
+ "sidebar": {
+ "popular": "Popular posts",
+ "tags": "Tags",
+ "subscribeTitle": "Subscribe to the journal",
+ "subscribeNote": "Email subscription is in preparation. Once open it will gather the month's posts and reading list, without intruding.",
+ "subscribeEmailLabel": "Email address",
+ "subscribeEmailPlaceholder": "you@example.com",
+ "subscribeSubmit": "Subscribe",
+ "subscribeNotice": "Subscription is not open yet. An announcement will follow on the site, thank you for waiting."
+ },
+ "archivePreview": {
+ "title": "Creative timeline",
+ "viewAll": "Full archive →"
+ },
+ "action": {
+ "backToTop": "Back to top"
+ },
+ "error": {
+ "loadFailed": "Failed to load the home page data, please try again later"
+ }
+}
diff --git a/apps/web/messages/en/ui.json5 b/apps/web/messages/en/ui.json5
index 9c97de1..3e1c088 100644
--- a/apps/web/messages/en/ui.json5
+++ b/apps/web/messages/en/ui.json5
@@ -2,6 +2,22 @@
"site": {
"name": "IdleRain Blogs"
},
+ "brand": {
+ "github": "GitHub"
+ },
+ "author": {
+ "name": "Developer",
+ "role": "Full-stack engineer",
+ "roleWithFields": "Full-stack engineer · programming and design",
+ "tagline": "A maker passionate about programming and design, weaving ideas with code and changing the world with technology.",
+ "note": "Writing code by day, writing prose by night. I believe in slow and solid accumulation, and favour clean structures and honest writing."
+ },
+ "meta": {
+ "minutesRead": "{{count}} min read",
+ "minutesReadApprox": "about {{count}} min",
+ "views_one": "{{count}} view",
+ "views_other": "{{count}} views"
+ },
"button": {
"save": "Save",
"cancel": "Cancel",
@@ -39,9 +55,6 @@
"githubHome": "GitHub home",
"themeToggle": "Toggle theme",
"aboutAuthor": "About the author",
- "aboutAuthorDesc": "A maker passionate about programming and design, weaving ideas with code and changing the world with technology.",
- "authorName": "Developer",
- "authorTitle": "Full-stack engineer",
"notifications": "Notifications",
"markAllRead": "Mark all read",
"noNotifications": "No notifications yet"
diff --git a/apps/web/messages/zh/home.json5 b/apps/web/messages/zh/home.json5
new file mode 100644
index 0000000..b03c72d
--- /dev/null
+++ b/apps/web/messages/zh/home.json5
@@ -0,0 +1,58 @@
+{
+ "seo": {
+ "title": "{{site}} - 把想法,编译成界面",
+ "description": "一个专注于技术分享和创意设计的个人博客,探索现代Web开发的无限可能。",
+ "descriptionShort": "一个专注于技术分享和创意设计的个人博客",
+ "keywords": "博客,技术,开发,设计,SvelteKit,Go,全栈开发"
+ },
+ "hero": {
+ "eyebrow": "手记 · 代码与生活",
+ "headlineLead": "把想法,",
+ "headlineTail": "编译成",
+ "headlineAccent": "界面",
+ "headlineNote": "// 工程 × 设计",
+ "intro": "记录工程实践的思考、城市漫游的见闻,以及那些深夜读完的书。相信缓慢而扎实的积累,偏爱干净的结构与诚实的文字。",
+ "ctaRead": "开始阅读",
+ "excerptLabel": "本月摘录",
+ "quote": "“把想清楚的事写下来,把写下来的事做出来。”",
+ "quoteAuthor": "—— 创刊编辑手记",
+ "specEngineering": "01 / 工程",
+ "specDesign": "02 / 设计",
+ "specLife": "03 / 生活",
+ "imprint": "{{site}} — EST. 2026",
+ "scrollHint": "Scroll"
+ },
+ "index": {
+ "title": "近期文章",
+ "count_one": "共 {{count}} 篇 · 持续更新",
+ "count_other": "共 {{count}} 篇 · 持续更新",
+ "emptyTitle": "创刊号正在筹备中,文章即将发布。",
+ "emptyNote": "可以先浏览版面与站点介绍,或前往归档页等待更新。",
+ "viewAll": "查看全部文章"
+ },
+ "featured": {
+ "badge": "精选",
+ "categoryFallback": "手记",
+ "readMore": "阅读全文"
+ },
+ "sidebar": {
+ "popular": "热门文章",
+ "tags": "标签",
+ "subscribeTitle": "订阅手记",
+ "subscribeNote": "邮件订阅正在筹备中,开放后将汇总当月文章与书单,不打扰。",
+ "subscribeEmailLabel": "邮箱地址",
+ "subscribeEmailPlaceholder": "you@example.com",
+ "subscribeSubmit": "订阅",
+ "subscribeNotice": "订阅功能暂未开放,开放后会在站内公告,感谢耐心等待。"
+ },
+ "archivePreview": {
+ "title": "创作年轮",
+ "viewAll": "完整归档 →"
+ },
+ "action": {
+ "backToTop": "回到顶部"
+ },
+ "error": {
+ "loadFailed": "首页数据加载失败,请稍后重试"
+ }
+}
diff --git a/apps/web/messages/zh/ui.json5 b/apps/web/messages/zh/ui.json5
index caab02d..b0531b6 100644
--- a/apps/web/messages/zh/ui.json5
+++ b/apps/web/messages/zh/ui.json5
@@ -2,6 +2,22 @@
"site": {
"name": "闲雨小筑"
},
+ "brand": {
+ "github": "GitHub"
+ },
+ "author": {
+ "name": "开发者",
+ "role": "全栈开发工程师",
+ "roleWithFields": "全栈工程师 · 编程与设计",
+ "tagline": "一个热爱编程和设计的创造者,用代码编织创意,用技术改变世界。",
+ "note": "白天写代码,晚上写字。相信缓慢而扎实的积累,偏爱干净的结构与诚实的文字。"
+ },
+ "meta": {
+ "minutesRead": "阅读 {{count}} 分钟",
+ "minutesReadApprox": "约 {{count}} 分钟",
+ "views_one": "{{count}} 次浏览",
+ "views_other": "{{count}} 次浏览"
+ },
"button": {
"save": "保存",
"cancel": "取消",
@@ -39,9 +55,6 @@
"githubHome": "GitHub 主页",
"themeToggle": "切换主题",
"aboutAuthor": "关于作者",
- "aboutAuthorDesc": "一个热爱编程和设计的创造者,用代码编织创意,用技术改变世界。",
- "authorName": "开发者",
- "authorTitle": "全栈开发工程师",
"notifications": "通知",
"markAllRead": "全部已读",
"noNotifications": "暂无通知"
diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json
index ea99ec8..0318c91 100644
--- a/apps/web/project.inlang/settings.json
+++ b/apps/web/project.inlang/settings.json
@@ -8,7 +8,8 @@
"pathPattern": {
"common": "./messages/{locale}/common.json5",
"ui": "./messages/{locale}/ui.json5",
- "auth": "./messages/{locale}/auth.json5"
+ "auth": "./messages/{locale}/auth.json5",
+ "home": "./messages/{locale}/home.json5"
}
},
"baseLocale": "zh",
diff --git a/apps/web/src/lib/components/home/BackToTop.svelte b/apps/web/src/lib/components/home/BackToTop.svelte
index 57a30af..540389c 100644
--- a/apps/web/src/lib/components/home/BackToTop.svelte
+++ b/apps/web/src/lib/components/home/BackToTop.svelte
@@ -1,6 +1,7 @@
- {`${SITE_NAME_ZH} - 把想法,编译成界面`}
-
-
+ {pageTitle}
+
+
-
-
+
+
-
-
+
+
@@ -46,12 +47,12 @@ const hotPosts = $derived(data.popular.slice(1))
diff --git a/apps/web/src/routes/(app)/+page.ts b/apps/web/src/routes/(app)/+page.ts
index 936868b..5cadda6 100644
--- a/apps/web/src/routes/(app)/+page.ts
+++ b/apps/web/src/routes/(app)/+page.ts
@@ -4,6 +4,7 @@ import { RESPONSE_CODE_SUCCESS } from '@myblog/shared'
import { ArticleAPI, TagAPI } from '$lib/api'
import type { PageLoad } from './$types'
import { error } from '@sveltejs/kit'
+import { m } from '$i18n'
// 首页无服务器端数据加载前显式关闭预渲染,接入业务数据后维持 SSR 按需渲染行为。
export const prerender = false
@@ -29,7 +30,7 @@ export const load: PageLoad = async () => {
popularResponse.code !== RESPONSE_CODE_SUCCESS ||
!popularResponse.data
) {
- throw error(503, '首页数据加载失败,请稍后重试')
+ throw error(503, m['home:error.loadFailed']())
}
const archives: ArticleArchiveYear[] =
diff --git a/docs/architecture-rules.md b/docs/architecture-rules.md
index 99cbd87..4b37088 100644
--- a/docs/architecture-rules.md
+++ b/docs/architecture-rules.md
@@ -12,11 +12,11 @@
## 1. 规则分级与核心机制
-| 级别 | 含义 | 违反后果 |
-|---|---|---|
-| 【铁律】 | 依赖方向、真相源、契约、权威、复用、数据加载六类结构性约束 | 必须返工 |
-| 【约定】 | 命名、格式、注释等风格约束 | 应当修正 |
-| 【债务】 | 已存在的违例,登记基线与验证命令 | **基线只减不增**(条目分册见 [`debt/`](./debt/README.md)) |
+| 级别 | 含义 | 违反后果 |
+| -------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
+| 【铁律】 | 依赖方向、真相源、契约、权威、复用、数据加载六类结构性约束 | 必须返工 |
+| 【约定】 | 命名、格式、注释等风格约束 | 应当修正 |
+| 【债务】 | 已存在的违例,登记基线与验证命令 | **基线只减不增**(条目分册见 [`debt/`](./debt/README.md)) |
**基线只减不增是本手册的核心执行机制**:登记为债务的违例不要求立即修复,但任何改动使债务指标恶化,即新增违例文件、新增实例化点或新增重复代码时判定违规。已接受取舍不设基线,改守其在登记条目中写明的上限与前提。每条债务附带验证命令,任务完成前 Agent 必须自检。
@@ -36,13 +36,13 @@ router → handler → service → repository → domain / model
**禁止的依赖(黑名单)**:
-| 禁止 | 理由 | 现状 |
-|---|---|---|
-| service → handler | 业务逻辑不得感知 HTTP | 已合规 |
-| repository → service / handler | 数据层不得承载业务 | 已合规 |
-| middleware → repository | HTTP 横切层不得直捣存储(终态:依赖 IdentityProvider 抽象) | 已合规(`identity.go` 以包内窄接口 `userLookup` 收敛,见 `debt/architecture.md` 第 1 条) |
-| router → repository(仅为拼装中间件) | 路由层不应持有数据访问句柄 | router 依赖 repository 归零 |
-| 任何包 → `database.GetDB()` 全局单例 | 破坏可测试性 | 已合规(仅 `cmd/myblog` 与 `cmd/seed` 使用) |
+| 禁止 | 理由 | 现状 |
+| ------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
+| service → handler | 业务逻辑不得感知 HTTP | 已合规 |
+| repository → service / handler | 数据层不得承载业务 | 已合规 |
+| middleware → repository | HTTP 横切层不得直捣存储(终态:依赖 IdentityProvider 抽象) | 已合规(`identity.go` 以包内窄接口 `userLookup` 收敛,见 `debt/architecture.md` 第 1 条) |
+| router → repository(仅为拼装中间件) | 路由层不应持有数据访问句柄 | router 依赖 repository 归零 |
+| 任何包 → `database.GetDB()` 全局单例 | 破坏可测试性 | 已合规(仅 `cmd/myblog` 与 `cmd/seed` 使用) |
### 2.2 前端允许的依赖图
@@ -55,11 +55,11 @@ apps/web, apps/admin(组合根:实例化与回调注入)
**禁止的依赖(黑名单)**:
-| 禁止 | 豁免 |
-|---|---|
-| packages/* → apps/* | 无(反向依赖一律非法) |
+| 禁止 | 豁免 |
+| -------------------------- | ------------------------------------------------------------------ |
+| packages/* → apps/* | 无(反向依赖一律非法) |
| 页面/组件 → 直接 import ky | 仅各应用 `src/lib/service/index.ts` 的令牌刷新直连(避免循环依赖) |
-| 页面/组件 → 自造 HTTP 请求 | 无,新接口一律先进 `packages/api` |
+| 页面/组件 → 自造 HTTP 请求 | 无,新接口一律先进 `packages/api` |
### 2.3 验证命令
@@ -107,11 +107,11 @@ git grep -n "interface BaseApiResponse" -- apps
**决策**:不引入 swaggo → OpenAPI → 前端类型生成的 codegen 链路,改用**双向类型锚定**三把锁,以最低成本实现与 codegen 同级的「物理不可漂移」:
-| 锁 | 机制 | 落地状态 |
-|---|---|---|
-| ① | Go handler 测试断言响应与 `contracts/fixtures/` 语义逐字节一致 | ✅ `handler/{fixture_locks,login_fixture,session_fixture,article_fixture,comment_fixture}_test.go`(**15/15 金样本**,覆盖认证会话、文章、评论三条核心链路) |
-| ② | TS 侧 `tsc --noEmit`(挂入 contract:check)+ `expectTypeOf(fixture).toExtend>` 单向合法实例校验 | ✅ `packages/api/src/contracts/__tests__/fixtures.test.ts`(15 用例,与 ① 一一对应) |
-| ③ | eslint `no-restricted-imports` 禁止应用层定义同构类型 | ✅ `apps/admin` 与 `apps/web` 双侧 eslint.config.js |
+| 锁 | 机制 | 落地状态 |
+| --- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| ① | Go handler 测试断言响应与 `contracts/fixtures/` 语义逐字节一致 | ✅ `handler/{fixture_locks,login_fixture,session_fixture,article_fixture,comment_fixture}_test.go`(**15/15 金样本**,覆盖认证会话、文章、评论三条核心链路) |
+| ② | TS 侧 `tsc --noEmit`(挂入 contract:check)+ `expectTypeOf(fixture).toExtend>` 单向合法实例校验 | ✅ `packages/api/src/contracts/__tests__/fixtures.test.ts`(15 用例,与 ① 一一对应) |
+| ③ | eslint `no-restricted-imports` 禁止应用层定义同构类型 | ✅ `apps/admin` 与 `apps/web` 双侧 eslint.config.js |
**覆盖对齐**:`TestFixtureCoverage` 以目录扫描为准,校验每个金样本都同时被 Go 侧断言与 TS 侧锚定引用,且引用的金样本确实存在;新增金样本却漏写任一端锚点即变红,金样本清单不依赖人工登记表维护。
@@ -127,6 +127,7 @@ Go 侧 `internal/handler/error_contract_test.go` 的 `TestErrorMappingMatchesCon
两侧任一方单独改动即变红,门禁入口同上。
**升级触发器**(命中任一则改用 codegen 方案):
+
1. 接口总数 > 80–100;
2. 出现第二客户端(移动端 / 第三方);
3. 需对外发布 API 文档;
@@ -151,10 +152,10 @@ Go 侧 `internal/handler/error_contract_test.go` 的 `TestErrorMappingMatchesCon
新增业务模块必须双端同时登记以下位置,缺一即未完成:
-| 端 | 必须创建/修改 |
-|---|---|
+| 端 | 必须创建/修改 |
+| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 后端 | `internal/model/.go`(如需)、领域实体与共享 DTO 进 `internal/domain`、请求 DTO 就近定义在所属 service 包、`internal/repository/.go`、`internal/service/.go`、`internal/handler/.go`、`internal/router/.go`、`cmd/myblog/deps.go` 装配 |
-| 前端 | `packages/api/src/modules//{types.ts, index.ts}`、`packages/api/src/index.ts` 导出、两应用 `src/lib/api/index.ts` 注册 |
+| 前端 | `packages/api/src/modules//{types.ts, index.ts}`、`packages/api/src/index.ts` 导出、两应用 `src/lib/api/index.ts` 注册 |
**历史反例**:`user_follow` 曾后端完整、前端零消费,后补齐 API 模块(`@myblog/api/modules/follow` + 两应用注册)。**此为"两端各自演进"的实证,模块对齐表的目的就是让这类偏差在发生当天可见。**
@@ -168,14 +169,14 @@ Go 侧 `internal/handler/error_contract_test.go` 的 `TestErrorMappingMatchesCon
### 5.1 权威归属表
-| 事实 | 唯一权威 | 非法副本 |
-|---|---|---|
+| 事实 | 唯一权威 | 非法副本 |
+| ------------------ | ---------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| 角色枚举与权限映射 | 后端(生产 `configs/config.yaml` `rbac` 节,经 `LoadRBACConfig` 加载) | 前端 `constants/auth.ts` 映射仅作未下发时的降级逻辑,**禁止新增第三份定义** |
-| "是否管理员"判定 | 后端 RBAC | 前端复刻(仅可做展示层优化) |
-| 文章状态流转 | `domain.Article` 行为方法 + service | 前端硬编码状态字符串比较 |
-| slug 生成 | `pkg/slug` + service 调用 | 前端自写 slugify |
-| 密码强度 | 后端 `service/user.go` | 前端正则复刻(仅可做输入提示,不得作为校验依据) |
-| token 刷新流程 | 各应用 `src/lib/service/index.ts`(裸 ky 直连版,单一实现) | —(`utils/jwt.ts` 的 `manualRefreshToken` 已删) |
+| "是否管理员"判定 | 后端 RBAC | 前端复刻(仅可做展示层优化) |
+| 文章状态流转 | `domain.Article` 行为方法 + service | 前端硬编码状态字符串比较 |
+| slug 生成 | `pkg/slug` + service 调用 | 前端自写 slugify |
+| 密码强度 | 后端 `service/user.go` | 前端正则复刻(仅可做输入提示,不得作为校验依据) |
+| token 刷新流程 | 各应用 `src/lib/service/index.ts`(裸 ky 直连版,单一实现) | —(`utils/jwt.ts` 的 `manualRefreshToken` 已删) |
### 5.2 实例化纪律
@@ -215,10 +216,10 @@ git grep -n "NewRBACService()" -- server
### 6.2 数据加载
-| 应用 | 新页面强制模式 | 存量处理 |
-|---|---|---|
-| web(SSR 路线) | `+page.server.ts`(需 SEO/会话)或 `+page.ts` load | 死 load 已清理,按此模式接入业务 |
-| admin(SPA 路线) | 优先 load + `.svelte.ts` 页面状态模块 | 胖组件 7→0 已清零;13 个页面取数已归位 load |
+| 应用 | 新页面强制模式 | 存量处理 |
+| ----------------- | -------------------------------------------------- | ------------------------------------------- |
+| web(SSR 路线) | `+page.server.ts`(需 SEO/会话)或 `+page.ts` load | 死 load 已清理,按此模式接入业务 |
+| admin(SPA 路线) | 优先 load + `.svelte.ts` 页面状态模块 | 胖组件 7→0 已清零;13 个页面取数已归位 load |
`admin` 侧再分两档:含客户端读写操作(列表筛选、分页、增删改)的页面必须配 `-page-state.svelte.ts` 及配套单测;只读页(无客户端读写)由 `+page.ts` 的 load 直出 page data,不建仅转发数据的空转模块。权限裁剪读 `@myblog/auth` 的本地认证状态,load 内禁止调用认证接口。
@@ -245,12 +246,12 @@ git grep -n "NewRBACService()" -- server
### 7.1 形态事实与后果
-| 维度 | 形态 | 后果 |
-|---|---|---|
-| 部署形态 | 应用进程、MySQL、网关各一份,同一 nginx 实例按端口区分入口 | 无副本与故障转移,单份容量即整站容量 |
-| 会话令牌 | 不透明随机串存于进程内存,身份唯一权威在服务端令牌表 | **服务重启或发布导致全体用户登出**,发布窗口需提前预告用户;令牌不跨进程共享 |
-| 请求限流 | 进程内计数 map,按客户端 IP 或用户维度计数 | 阈值即**单进程**口径;进程重启后计数清零 |
-| 故障处理 | **无自动故障转移** | **故障即停站**,恢复依赖人工介入与重启;无 RTO 承诺,RPO 为 24 小时(见 `operations/backup-restore.md`) |
+| 维度 | 形态 | 后果 |
+| -------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
+| 部署形态 | 应用进程、MySQL、网关各一份,同一 nginx 实例按端口区分入口 | 无副本与故障转移,单份容量即整站容量 |
+| 会话令牌 | 不透明随机串存于进程内存,身份唯一权威在服务端令牌表 | **服务重启或发布导致全体用户登出**,发布窗口需提前预告用户;令牌不跨进程共享 |
+| 请求限流 | 进程内计数 map,按客户端 IP 或用户维度计数 | 阈值即**单进程**口径;进程重启后计数清零 |
+| 故障处理 | **无自动故障转移** | **故障即停站**,恢复依赖人工介入与重启;无 RTO 承诺,RPO 为 24 小时(见 `operations/backup-restore.md`) |
### 7.2 变更前提(当前不触发)
@@ -283,27 +284,28 @@ git grep -n "SetTrustedProxies" -- server
> 完整条目(状态、基线或上限、验证命令、红线)按关注域分册登记在 `docs/debt/`,机制与维护流程见 [`debt/README.md`](./debt/README.md)。
> 本节只保留索引:触碰相关区域前先按「所属分册」读对应条目,任务自检时核对债务基线不恶化、已接受取舍不逾越上限。
-| 条目 | 所属分册 | 红线(一句话) |
-|---|---|---|
-| service/middleware/router import repository | [`debt/architecture.md`](./debt/architecture.md) 第 1 条 | middleware 与 router 不得 import repository;service 属允许边 |
-| router 重复定义 handler 接口 + `interface{}` 断言 | [`debt/architecture.md`](./debt/architecture.md) 第 2 条 | 禁止重新引入 |
-| `RBACService` 生产实例化 | [`debt/architecture.md`](./debt/architecture.md) 第 3 条 | 禁止新增实例化点 |
-| 双 User 模型同写 users 表 | [`debt/architecture.md`](./debt/architecture.md) 第 4 条 | 新字段只加 `domain.User` |
-| 应用层影子类型层 | [`debt/architecture.md`](./debt/architecture.md) 第 5 条 | 禁止重新引入,类型一律来自 `@myblog/api` |
-| follow 模块仅后端 | [`debt/architecture.md`](./debt/architecture.md) 第 6 条 | 关注数据仅经 service 域端点读写 |
-| 业务错误未归哨兵导致分档退化为 500 | [`debt/architecture.md`](./debt/architecture.md) 第 7 条 | 新增业务错误必须包装哨兵并同步登记契约 |
-| 两 app 基础设施逐字重复 | [`debt/frontend.md`](./debt/frontend.md) 第 1 条 | 修改任一必须同步另一份 |
-| admin 认证工具三轨并行 | [`debt/frontend.md`](./debt/frontend.md) 第 2 条 | 禁止新增认证工具文件与双轨回退 |
-| admin 胖组件 + onMount 取数 | [`debt/frontend.md`](./debt/frontend.md) 第 3 条 | 新页面禁用 onMount 取数;行数与取数口径均已清零,constants 不得引入图标库 |
-| web 首页 load 死代码 | [`debt/frontend.md`](./debt/frontend.md) 第 4 条 | 新页面禁用 load 调认证接口 |
-| 401 文案匹配 | [`debt/frontend.md`](./debt/frontend.md) 第 5 条 | 禁止回退文案匹配 |
-| admin 重写 `$ui` 已有组件(含 web 分页例外) | [`debt/frontend.md`](./debt/frontend.md) 第 6 条 | 新分页一律 `$ui`,禁止新增第三处实现 |
-| web 界面多语言局部接入 | [`debt/frontend.md`](./debt/frontend.md) 第 7 条 | 已接入文件禁止回退硬编码 |
-| 字典页窄屏交互与工具栏布局遗留 | [`debt/frontend.md`](./debt/frontend.md) 第 8 条 | 禁止回退为嵌套交互元素,窄屏列折叠与焦点环不得移除 |
-| 公开端点直出实体泄漏个人信息 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 1 条 | 个人信息须经窄化 DTO 或字段白名单 |
-| 文章响应泄漏作者审计字段 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 2 条 | 新增审计字段默认 `json:"-"` |
-| WAF 内容级黑名单的固有误伤面 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 3 条 | 阻止模式必须先红后绿并配两组用例 |
-| 代理信任链未收敛导致 `ClientIP()` 可伪造 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 4 条 | 仅 `security.trusted_proxies` 内来源可参与解析,禁止回退为信任全部来源 |
+| 条目 | 所属分册 | 红线(一句话) |
+| ------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------- |
+| service/middleware/router import repository | [`debt/architecture.md`](./debt/architecture.md) 第 1 条 | middleware 与 router 不得 import repository;service 属允许边 |
+| router 重复定义 handler 接口 + `interface{}` 断言 | [`debt/architecture.md`](./debt/architecture.md) 第 2 条 | 禁止重新引入 |
+| `RBACService` 生产实例化 | [`debt/architecture.md`](./debt/architecture.md) 第 3 条 | 禁止新增实例化点 |
+| 双 User 模型同写 users 表 | [`debt/architecture.md`](./debt/architecture.md) 第 4 条 | 新字段只加 `domain.User` |
+| 应用层影子类型层 | [`debt/architecture.md`](./debt/architecture.md) 第 5 条 | 禁止重新引入,类型一律来自 `@myblog/api` |
+| follow 模块仅后端 | [`debt/architecture.md`](./debt/architecture.md) 第 6 条 | 关注数据仅经 service 域端点读写 |
+| 业务错误未归哨兵导致分档退化为 500 | [`debt/architecture.md`](./debt/architecture.md) 第 7 条 | 新增业务错误必须包装哨兵并同步登记契约 |
+| 后端响应文案不随语言切换 | [`debt/architecture.md`](./debt/architecture.md) 第 8 条 | 前端后备文案禁止回退硬编码,落地前不得按错误码另建文案映射 |
+| 两 app 基础设施逐字重复 | [`debt/frontend.md`](./debt/frontend.md) 第 1 条 | 修改任一必须同步另一份 |
+| admin 认证工具三轨并行 | [`debt/frontend.md`](./debt/frontend.md) 第 2 条 | 禁止新增认证工具文件与双轨回退 |
+| admin 胖组件 + onMount 取数 | [`debt/frontend.md`](./debt/frontend.md) 第 3 条 | 新页面禁用 onMount 取数;行数与取数口径均已清零,constants 不得引入图标库 |
+| web 首页 load 死代码 | [`debt/frontend.md`](./debt/frontend.md) 第 4 条 | 新页面禁用 load 调认证接口 |
+| 401 文案匹配 | [`debt/frontend.md`](./debt/frontend.md) 第 5 条 | 禁止回退文案匹配 |
+| admin 重写 `$ui` 已有组件(含 web 分页例外) | [`debt/frontend.md`](./debt/frontend.md) 第 6 条 | 新分页一律 `$ui`,禁止新增第三处实现 |
+| web 界面多语言局部接入 | [`debt/frontend.md`](./debt/frontend.md) 第 7 条 | 已接入文件禁止回退硬编码 |
+| 字典页窄屏交互与工具栏布局遗留 | [`debt/frontend.md`](./debt/frontend.md) 第 8 条 | 禁止回退为嵌套交互元素,窄屏列折叠与焦点环不得移除 |
+| 公开端点直出实体泄漏个人信息 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 1 条 | 个人信息须经窄化 DTO 或字段白名单 |
+| 文章响应泄漏作者审计字段 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 2 条 | 新增审计字段默认 `json:"-"` |
+| WAF 内容级黑名单的固有误伤面 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 3 条 | 阻止模式必须先红后绿并配两组用例 |
+| 代理信任链未收敛导致 `ClientIP()` 可伪造 | [`debt/security-runtime.md`](./debt/security-runtime.md) 第 4 条 | 仅 `security.trusted_proxies` 内来源可参与解析,禁止回退为信任全部来源 |
---
@@ -312,15 +314,16 @@ git grep -n "SetTrustedProxies" -- server
> 此处登记历史重构的分期内容与验收口径,供回顾时对照。
> 每完成一项债务修复必须同步更新 `docs/debt/` 对应条目与第 8 节索引,并更新本节状态,保持登记与代码一致。
-| 阶段 | 内容 | 完成的债务 | 验收口径 |
-|---|---|---|---|
-| 阶段一 结构归位与错误分档 | 删 router 重复接口与不可达代码;错误分档(哨兵错误→404/403/400);令牌表加锁;web 死 load 清理;建立 `contracts/` 目录 | router 重复接口、web 死 load、401 判定均已修复;令牌表已加锁;`RBACService` 生产实例化点仅 1 处;not-found 哨兵→404 已落地,403/400 随错误码契约落地;全部业务错误归哨兵完成,认证失败经 `ErrUnauthenticated`→401,handler 私有映射分支清零 | ✅ 项目自检命令(后端 build/vet/test、两应用类型检查、lint 与 format)全绿 |
-| 阶段二 类型归位 | 建立 `internal/domain`,合并双 User,service/middleware/router 签名切换为 domain 类型;前端 auth 下沉共享包、影子类型清除 | 双 User 模型与影子类型层已修复;两 app 重复代码大幅减少(auth store 下沉);service 层 repository 依赖由 12 降至 11 | ✅ 依赖方向基线下降;auth store diff 为零 |
-| 阶段三 契约切换 | handler DTO 分离;`contracts/` + 三把锁双向锚定(替代 codegen);401 改错误码判定 | 401 文案匹配与审计字段泄漏已修复;三把锁已落地(`pnpm run contract:check`) | ✅ 影子类型归零;漂移必当天变红 |
-| 阶段四 横切归位与权限下发 | 中间件坍缩为 IdentityProvider 策略;组合根按域装配;RBAC 权限表迁数据源并下发;admin 胖组件拆分、users 搜索推回后端 | `RBACService` 生产实例化点仅 1 处;users 跨页补偿与 admin 分页均已修复;RBAC 迁 config.yaml 完成;permissions 下发完成;follow API 模块已补齐;IdentityProvider 中间件坍缩完成(router 依赖 repository 归零、middleware 1 处);认证工具已统一;admin 胖组件行数口径 7→0,13 个页面取数归位到 load(含 11 个页面状态模块与配套单测),取数口径 6→0,`onMount` 仅余鉴权 2 处 | 权限定义全栈唯一;认证工具单轨 ✅;admin 行数与取数两条基线均归零 ✅ |
-| 阶段五 扩展点 | 后端 ContentRenderer 内容策略接口(当前 `pkg/markdown` 已直接承接 Markdown 渲染,策略接口化待做);web 业务页面已按"公开数据 SSR + 个性化数据客户端补拉"现状接入,token 迁 cookie 已完成 | — | 新文章类型 = 插入实现,非逐层打洞 |
-| 阶段六 代理信任链收敛 | 引擎构造期接入信任链白名单;`NewRouter` 改为返回错误;配置校验拒绝覆盖全部地址的取值;补伪造转发头的四态用例 | 代理信任链未收敛导致 `ClientIP()` 可伪造(`docs/debt/security-runtime.md` 第 4 条) | ✅ 接线前实测三例失败且日志 `clientIp` 为伪造值;接线后伪造转发头不再影响 `ClientIP()` |
-| 阶段七 依赖边口径订正 | 中间件在包内声明消费方窄接口,收敛对 repository 包的依赖;债务基线拆分为允许边与违例边,同步订正 §2.1、§2.3 与 CI 断言 | service/middleware/router import repository(`docs/debt/architecture.md` 第 1 条) | ✅ middleware 与 router 的违例 import 归零;查询参数留在 repository 经确认接受;CI 基线断言由 ≤13 改为 =0 |
+| 阶段 | 内容 | 完成的债务 | 验收口径 |
+| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
+| 阶段一 结构归位与错误分档 | 删 router 重复接口与不可达代码;错误分档(哨兵错误→404/403/400);令牌表加锁;web 死 load 清理;建立 `contracts/` 目录 | router 重复接口、web 死 load、401 判定均已修复;令牌表已加锁;`RBACService` 生产实例化点仅 1 处;not-found 哨兵→404 已落地,403/400 随错误码契约落地;全部业务错误归哨兵完成,认证失败经 `ErrUnauthenticated`→401,handler 私有映射分支清零 | ✅ 项目自检命令(后端 build/vet/test、两应用类型检查、lint 与 format)全绿 |
+| 阶段二 类型归位 | 建立 `internal/domain`,合并双 User,service/middleware/router 签名切换为 domain 类型;前端 auth 下沉共享包、影子类型清除 | 双 User 模型与影子类型层已修复;两 app 重复代码大幅减少(auth store 下沉);service 层 repository 依赖由 12 降至 11 | ✅ 依赖方向基线下降;auth store diff 为零 |
+| 阶段三 契约切换 | handler DTO 分离;`contracts/` + 三把锁双向锚定(替代 codegen);401 改错误码判定 | 401 文案匹配与审计字段泄漏已修复;三把锁已落地(`pnpm run contract:check`) | ✅ 影子类型归零;漂移必当天变红 |
+| 阶段四 横切归位与权限下发 | 中间件坍缩为 IdentityProvider 策略;组合根按域装配;RBAC 权限表迁数据源并下发;admin 胖组件拆分、users 搜索推回后端 | `RBACService` 生产实例化点仅 1 处;users 跨页补偿与 admin 分页均已修复;RBAC 迁 config.yaml 完成;permissions 下发完成;follow API 模块已补齐;IdentityProvider 中间件坍缩完成(router 依赖 repository 归零、middleware 1 处);认证工具已统一;admin 胖组件行数口径 7→0,13 个页面取数归位到 load(含 11 个页面状态模块与配套单测),取数口径 6→0,`onMount` 仅余鉴权 2 处 | 权限定义全栈唯一;认证工具单轨 ✅;admin 行数与取数两条基线均归零 ✅ |
+| 阶段五 扩展点 | 后端 ContentRenderer 内容策略接口(当前 `pkg/markdown` 已直接承接 Markdown 渲染,策略接口化待做);web 业务页面已按"公开数据 SSR + 个性化数据客户端补拉"现状接入,token 迁 cookie 已完成 | — | 新文章类型 = 插入实现,非逐层打洞 |
+| 阶段六 代理信任链收敛 | 引擎构造期接入信任链白名单;`NewRouter` 改为返回错误;配置校验拒绝覆盖全部地址的取值;补伪造转发头的四态用例 | 代理信任链未收敛导致 `ClientIP()` 可伪造(`docs/debt/security-runtime.md` 第 4 条) | ✅ 接线前实测三例失败且日志 `clientIp` 为伪造值;接线后伪造转发头不再影响 `ClientIP()` |
+| 阶段七 依赖边口径订正 | 中间件在包内声明消费方窄接口,收敛对 repository 包的依赖;债务基线拆分为允许边与违例边,同步订正 §2.1、§2.3 与 CI 断言 | service/middleware/router import repository(`docs/debt/architecture.md` 第 1 条) | ✅ middleware 与 router 的违例 import 归零;查询参数留在 repository 经确认接受;CI 基线断言由 ≤13 改为 =0 |
+| 阶段八 界面多语言分批接入 | web 界面文案按面分批接入 paraglide 词表,词表按面拆 namespace 并固化插值与复数写法;每批同步登记债务基线与本节 | web 界面多语言局部接入(`docs/debt/frontend.md` 第 7 条)推进中;后端响应文案不随语言切换(`docs/debt/architecture.md` 第 8 条)待接入 | ✅ 已接入文件禁止回退硬编码;`git grep -ln "\$i18n" -- apps/web/src` 的命中面逐批递增且只增不减,各 namespace 中英键集合一致 |
---
diff --git a/docs/debt/README.md b/docs/debt/README.md
index d40b011..a7aa0a2 100644
--- a/docs/debt/README.md
+++ b/docs/debt/README.md
@@ -5,13 +5,13 @@
## 分组
-| 分册 | 覆盖范围 | 条目数 |
-|---|---|---|
-| [`architecture.md`](./architecture.md) | 依赖方向、结构归位、类型真相源、模块对齐、错误语义归位 | 7 |
-| [`frontend.md`](./frontend.md) | 两应用复用、认证工具、页面结构与取数、分页、i18n、UI 交互 | 8 |
-| [`security-runtime.md`](./security-runtime.md) | 公开端点隐私、审计字段、WAF、代理信任链 | 4 |
+| 分册 | 覆盖范围 | 条目数 |
+| ---------------------------------------------- | --------------------------------------------------------- | ------ |
+| [`architecture.md`](./architecture.md) | 依赖方向、结构归位、类型真相源、模块对齐、错误语义归位 | 8 |
+| [`frontend.md`](./frontend.md) | 两应用复用、认证工具、页面结构与取数、分页、i18n、UI 交互 | 8 |
+| [`security-runtime.md`](./security-runtime.md) | 公开端点隐私、审计字段、WAF、代理信任链 | 4 |
-合计 19 条,与 `docs/architecture-rules.md` 第 8 节的索引表一一对应。
+合计 20 条,与 `docs/architecture-rules.md` 第 8 节的索引表一一对应。
> 相邻登记:契约与实现之间若再现映射冲突,登记在 `contracts/errors.yaml` 的「实现偏差」节,该节清除后自行删除;历史偏差(登录与刷新的私有 401 分支)已随 `architecture.md` 第 7 条修复一并清除。
diff --git a/docs/debt/architecture.md b/docs/debt/architecture.md
index 164faac..0c509ac 100644
--- a/docs/debt/architecture.md
+++ b/docs/debt/architecture.md
@@ -55,3 +55,10 @@
`{ git grep -n 'fmt.Errorf(' -- internal/service ':(exclude)*_test.go' | grep -v '%w'; git grep -n 'errors.New(' -- internal/service ':(exclude)*_test.go' ':(exclude)internal/service/errors.go'; } | wc -l`
应输出 0;分档一致性由 `go test ./internal/handler/ -run TestErrorMappingMatchesContract -count=1` 与 `pnpm run contract:check` 锚定。
- **红线**:新增业务校验失败、认证失败与资源未找到必须包装对应哨兵(`service.ErrUnauthenticated`、`service.ErrInvalidRequest`、`domain.ErrXxxNotFound` 等),并同步登记 `contracts/errors.yaml` 的 mapping 节与 `handler` 分档注册表;禁止以裸错误表达同类语义,禁止在模块内新增私有映射分支。
+
+## 8. 后端响应文案不随语言切换
+
+- **状态**:推进中,随界面多语言分批接入推进。
+- **基线**:接口响应同时携带 `code` 与 `message`,前端 8 处以 `response.message || 后备文案` 直出后端字符串(`ArticleActions` 2、`CommentSection` 1、`FollowButton` 1、`login` 1、`profile` 2、`FriendlyLinkDialog` 1),其中 7 处后备仍为硬编码中文、仅 `FriendlyLinkDialog` 已接入词表。后端 `message` 是 service 与 domain 层哨兵错误的原始文本,经 `handler.HandleServiceError` 的 `response.Error(c, mapping.Code, err.Error())` 直出,无语言维度;`message` 命中时前端后备不生效,en 模式下提示仍为中文。`internal/middleware/language.go` 已把语言写入请求上下文,具备接入条件。
+- **验证命令**:`git grep -n "response.message" -- apps/web/src`(当前 9 处,含 `ssr.ts` 的管道传递);`git grep -n "err.Error()" -- server/internal/handler/error.go`(后端文案直出点,应为 1 处且无本地化分支)。
+- **红线**:前端后备文案禁止回退硬编码;前端若改为按错误码取词,须与 `contracts/errors.yaml` 的 mapping 节在同一变更窗口内同步,禁止另建与契约脱钩的映射表。
diff --git a/docs/debt/frontend.md b/docs/debt/frontend.md
index c0aef7b..c6021e7 100644
--- a/docs/debt/frontend.md
+++ b/docs/debt/frontend.md
@@ -55,9 +55,10 @@
## 7. web 界面多语言局部接入
- **状态**:推进中,分批接入。
-- **基线**:语言切换对 Header、Footer、错误页真实生效(含 NotificationBell、FriendlyLinkDialog 两个 Header 子组件与 demo 页),其余页面文案硬编码中文,en 模式下界面为混合语言;词表文件必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败)。
-- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(已接入面:Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo)。
-- **红线**:已接入文件禁止回退硬编码;新增用户可见文案优先经 `m.*` 词表取词;其余页面接入待页面大变动后分批推进。
+- **基线**:已接入面 **12** 个文件——Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo 页,以及**首页整面**:`(app)/+page.svelte`(SEO 与年轮预览)、`(app)/+page.ts`(加载失败文案)与 `lib/components/home/` 下 HeroSection、PostIndexSection、FeaturedStory、BackToTop 四个组件。Header 的站名与作者身份已并入 `ui` 共享词条(`ui:site.name`、`ui:author.*`、`ui:brand.github`、`ui:meta.*`),页面标题不再引用中文站名常量。其余页面文案仍硬编码中文,en 模式下界面为混合语言。
+- **词表约定**:按面拆分为独立 namespace 并在 `project.inlang/settings.json` 的 `pathPattern` 注册,`ui` 只承载跨面 chrome 与共享词;插值必须用 i18next 双花括号 `{{param}}`,单花括号会被当作字面量原样输出;计数词条写 `_one`/`_other` 两个变体,参数名必须为 `count` 才参与 `Intl.PluralRules` 选择,变体缺失时取词回退为原始 key 字符串;词表必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败)。
+- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(当前 12 个文件,逐批递增);`pnpm --filter @myblog/web run generate:i18n` 后核对 `messages/{zh,en}` 各 namespace 的键集合与条数一致(当前 ui 74 / home 40 / auth 7 / common 4)。
+- **红线**:已接入文件禁止回退硬编码,不得在已接入文件里新增中文字面量;新增用户可见文案优先经 `m.*` 取词,页面文案进本面 namespace 不塞回 `ui`;其余页面待页面大变动后分批推进。
## 8. 字典页窄屏交互与工具栏布局遗留
diff --git a/docs/development.md b/docs/development.md
index c58d4c8..134b0d5 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -63,20 +63,20 @@ MyBlog 采用 Monorepo 架构,将前后端代码统一管理在一个仓库中
后端按领域划分为以下业务模块,每个模块遵循 handler → service → repository 三层结构,接口统一定义在各层实现所在包:
-| 模块 | handler | service | repository | 说明 |
-|------|---------|---------|------------|------|
-| 用户管理 | `handler/user.go` | `service/user.go` | `repository/user.go` | 登录、CRUD、不透明双令牌 |
-| 文章管理 | `handler/article.go` | `service/article.go` | `repository/article.go` | 文章 CRUD、发布归档、互动 |
-| 分类管理 | `handler/category.go` | `service/category.go` | `repository/category.go` | 分类树形管理 |
-| 标签管理 | `handler/tag.go` | `service/tag.go` | `repository/tag.go` | 标签与热门标签 |
-| 评论管理 | `handler/comment.go` | `service/comment.go` | `repository/comment.go` | 评论与审核状态机 |
-| 媒体文件 | `handler/media.go` | `service/media.go` | `repository/media.go` | 上传与管理 |
-| 系统设置 | `handler/setting.go` | `service/setting.go` | `repository/setting.go` | 配置与脱敏 |
-| 友情链接 | `handler/friendly_link.go` | `service/friendly_link.go` | `repository/friendly_link.go` | 友链申请与审核 |
-| 站点统计 | `handler/stats.go` | `service/stats.go` | `repository/stats.go` | 运营数据分析 |
-| 站内通知 | `handler/notification.go` | `service/notification.go` | `repository/notification.go` | 消息中心 |
-| 用户关注 | `handler/user_follow.go` | `service/user_follow.go` | `repository/user_follow.go` | 关注关系 |
-| 数据字典 | `handler/dict.go` | `service/dict.go` | `repository/dict.go` | 字典类型与字典项 |
+| 模块 | handler | service | repository | 说明 |
+| -------- | -------------------------- | -------------------------- | ----------------------------- | ------------------------- |
+| 用户管理 | `handler/user.go` | `service/user.go` | `repository/user.go` | 登录、CRUD、不透明双令牌 |
+| 文章管理 | `handler/article.go` | `service/article.go` | `repository/article.go` | 文章 CRUD、发布归档、互动 |
+| 分类管理 | `handler/category.go` | `service/category.go` | `repository/category.go` | 分类树形管理 |
+| 标签管理 | `handler/tag.go` | `service/tag.go` | `repository/tag.go` | 标签与热门标签 |
+| 评论管理 | `handler/comment.go` | `service/comment.go` | `repository/comment.go` | 评论与审核状态机 |
+| 媒体文件 | `handler/media.go` | `service/media.go` | `repository/media.go` | 上传与管理 |
+| 系统设置 | `handler/setting.go` | `service/setting.go` | `repository/setting.go` | 配置与脱敏 |
+| 友情链接 | `handler/friendly_link.go` | `service/friendly_link.go` | `repository/friendly_link.go` | 友链申请与审核 |
+| 站点统计 | `handler/stats.go` | `service/stats.go` | `repository/stats.go` | 运营数据分析 |
+| 站内通知 | `handler/notification.go` | `service/notification.go` | `repository/notification.go` | 消息中心 |
+| 用户关注 | `handler/user_follow.go` | `service/user_follow.go` | `repository/user_follow.go` | 关注关系 |
+| 数据字典 | `handler/dict.go` | `service/dict.go` | `repository/dict.go` | 字典类型与字典项 |
#### 依赖注入
@@ -88,20 +88,20 @@ MyBlog 采用 Monorepo 架构,将前后端代码统一管理在一个仓库中
#### 应用拆分
-| 应用 | 定位 | 特性 | 开发端口 |
-| --- | --- | --- | --- |
-| `apps/web`(@myblog/web) | 前台 toC | 博客业务页面(首页/目录/详情/分类/归档/作者页/登录/收藏)+ demo 页 + i18n(paraglide) | 8899 |
-| `apps/admin`(@myblog/admin) | 后台 toB | 管理控制台 + 登录页,基准路径 `/admin`,无 i18n | 9988 |
+| 应用 | 定位 | 特性 | 开发端口 |
+| ----------------------------- | -------- | -------------------------------------------------------------------------------------- | -------- |
+| `apps/web`(@myblog/web) | 前台 toC | 博客业务页面(首页/目录/详情/分类/归档/作者页/登录/收藏)+ demo 页 + i18n(paraglide) | 8899 |
+| `apps/admin`(@myblog/admin) | 后台 toB | 管理控制台 + 登录页,基准路径 `/admin`,无 i18n | 9988 |
#### 公共包
-| 包 | 职责 | 关键依赖 |
-| --- | --- | --- |
-| `@myblog/shared` | 纯工具(`cn`、深拷贝、防抖节流等)+ 通用类型 + 常量(站点常量与后端响应码 `RESPONSE_CODE_*`),不依赖 SvelteKit/Svelte | clsx、tailwind-merge、mitt |
-| `@myblog/http` | `createHttpClient` 工厂(ky 封装,认证回调注入) | ky、@myblog/shared |
-| `@myblog/api` | 后端接口模块与响应类型(article/category/comment/dict/follow/friendlyLink/media/notification/setting/stats/tag/user 共 12 个模块工厂) | @myblog/http、@myblog/shared |
-| `@myblog/auth` | 认证会话组装:`createAuthStore` 工厂(注入式,逻辑两应用共享) | @myblog/api、@myblog/shared(svelte 为 peerDependency) |
-| `@myblog/ui` | shadcn-svelte 基础组件,保持 stock,主题经各应用设计令牌注入 | bits-ui、vaul-svelte 等 |
+| 包 | 职责 | 关键依赖 |
+| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
+| `@myblog/shared` | 纯工具(`cn`、深拷贝、防抖节流等)+ 通用类型 + 常量(站点常量与后端响应码 `RESPONSE_CODE_*`),不依赖 SvelteKit/Svelte | clsx、tailwind-merge、mitt |
+| `@myblog/http` | `createHttpClient` 工厂(ky 封装,认证回调注入) | ky、@myblog/shared |
+| `@myblog/api` | 后端接口模块与响应类型(article/category/comment/dict/follow/friendlyLink/media/notification/setting/stats/tag/user 共 12 个模块工厂) | @myblog/http、@myblog/shared |
+| `@myblog/auth` | 认证会话组装:`createAuthStore` 工厂(注入式,逻辑两应用共享) | @myblog/api、@myblog/shared(svelte 为 peerDependency) |
+| `@myblog/ui` | shadcn-svelte 基础组件,保持 stock,主题经各应用设计令牌注入 | bits-ui、vaul-svelte 等 |
依赖方向单向无环:应用 → `ui` → `shared`;应用 → `auth`/`http` → `shared`;应用 → `api` → `http` + `shared`。
@@ -150,11 +150,11 @@ apps/admin/src/ # 后台
### 环境要求
-| 工具 | 版本要求 | 说明 |
-| ------- | -------- | ------------------------------- |
-| Go | 1.26.9 | 后端开发语言 |
-| Node.js | 22+ | JavaScript 运行时与脚本执行器 |
-| MySQL | 8.0+ | 数据库服务 |
+| 工具 | 版本要求 | 说明 |
+| ------- | -------- | ----------------------------- |
+| Go | 1.26.9 | 后端开发语言 |
+| Node.js | 22+ | JavaScript 运行时与脚本执行器 |
+| MySQL | 8.0+ | 数据库服务 |
Go 版本的单一事实来源为 `server/go.mod` 的 `go` 指令(当前 `1.26.9`),CI 经 `actions/setup-go` 的 `go-version-file` 读取该值;本地低于该版本时由 `GOTOOLCHAIN` 自动下载对应工具链。
@@ -329,11 +329,11 @@ git diff --cached --name-only # 核对清单后再执行 git commit
两应用各有两个由 `unplugin-auto-import` 写入的文件,仓库根另有一个无消费方的历史残留,**均入库跟踪但不由人工维护**:
-| 文件 | 写入者 | 说明 |
-|---|---|---|
-| `apps//typings/auto-imports.d.ts` | 该应用的 vite 插件 | 自动导入的全局类型声明 |
-| `apps//.eslintrc-auto-import.js` | 该应用的 vite 插件 | 同名全局变量的 eslint globals,被该应用 `eslint.config.js` 直接 import |
-| `.eslintrc-auto-import.js`(仓库根) | 某次以仓库根为工作目录的运行 | **无任何消费方**,改它不影响任何门禁 |
+| 文件 | 写入者 | 说明 |
+| -------------------------------------- | ---------------------------- | ---------------------------------------------------------------------- |
+| `apps//typings/auto-imports.d.ts` | 该应用的 vite 插件 | 自动导入的全局类型声明 |
+| `apps//.eslintrc-auto-import.js` | 该应用的 vite 插件 | 同名全局变量的 eslint globals,被该应用 `eslint.config.js` 直接 import |
+| `.eslintrc-auto-import.js`(仓库根) | 某次以仓库根为工作目录的运行 | **无任何消费方**,改它不影响任何门禁 |
该插件以追加方式写入声明:**误加或误删的声明不会随下次运行自动消失**,改错必须手工修正。调整自动导入白名单后,应显式重跑一次前端构建(vite 插件只在构建与开发服务启动时写入,`svelte-check` 不会触发),并核对上述文件的差异是否符合预期;出现与本轮改动无关的差异时不要顺手提交。
@@ -512,9 +512,13 @@ const request = createHttpClient({
// 会话令牌存放于 HttpOnly Cookie,由浏览器自动携带;
// 回调不读取任何令牌,只负责在服务端拒绝当前会话时发起续期。
refreshSession: () => authStore.refreshSingleFlight(refreshSession),
- onAuthFailure: async message => { /* 清除本地认证状态并跳转登录页 */ }
+ onAuthFailure: async message => {
+ /* 清除本地认证状态并跳转登录页 */
+ }
},
- onError: message => { /* 界面统一提示,如 toast.error(message) */ }
+ onError: message => {
+ /* 界面统一提示,如 toast.error(message) */
+ }
})
// 应用侧 src/lib/api/index.ts:实例化接口模块
@@ -534,17 +538,20 @@ const updated = await UserAPI.updateUser({ id: user.id, username: 'new-name', em
`@myblog/api` 的 user 模块存在两个合法镜像形状,各自对应不同的后端输出,禁止混用:
-| 类型 | 镜像源 | 对应端点 |
-| --- | --- | --- |
-| `User` | `domain.User.ToResponse()` 裁剪形状 | 登录、`users/list`、`users/get` |
+| 类型 | 镜像源 | 对应端点 |
+| ------------- | ---------------------------------------------------------- | --------------------------------------- |
+| `User` | `domain.User.ToResponse()` 裁剪形状 | 登录、`users/list`、`users/get` |
| `ProfileUser` | `domain.User` 自助全量形状(含 bio/website/coverImage 等) | `users/profile`、`users/profile/update` |
修改后端任一形状的输出字段集时,必须同步 `@myblog/api/modules/user/types.ts` 对应类型并运行 `contract:check`(类型镜像义务)。两类形状的 `birthday` 均为 `string | null`:后端经 `datetime.JSONDate` 输出,零值序列化为 `null` 而非空字符串。
#### 5. 界面多语言(仅 apps/web)
-- 用户可见文案经 `$i18n` 的 `m['ui:...']()` 取词;接入现状与红线见 [`architecture-rules.md`](./architecture-rules.md)(Header/Footer/错误页已接入,其余页面待页面大变动后分批,已接入文件禁止回退硬编码)
-- `messages/*.json5` 必须保持 **JSON 兼容写法**(双引号、无尾逗号):paraglide 编译器按严格 JSON 解析,无引号键/尾逗号/单引号会直接编译失败
+- 用户可见文案经 `$i18n` 的 `m[':']()` 取词;接入现状与红线见 [`debt/frontend.md`](./debt/frontend.md) 第 7 条(Header/Footer/错误页/首页已接入,其余页面待页面大变动后分批,已接入文件禁止回退硬编码)
+- **namespace 按面拆分**:`ui` 只承载跨面 chrome 与共享词(站名、作者身份、品牌名、通用元信息),页面文案进各自面的 namespace;新增 namespace 须在 `apps/web/project.inlang/settings.json` 的 `plugin.inlang.i18next.pathPattern` 注册,并在 `messages/zh` 与 `messages/en` 各建同名文件
+- **插值用双花括号**:`{{param}}` 是 i18next 语法,取词写作 `m['home:seo.title']({ site })`;写成单花括号 `{param}` 会被当作字面量原样输出,生成的取词函数也不会声明该入参。词条首尾的空格具有语义,英文词条常以词尾空格衔接相邻的强调节点,不手工去除
+- **计数词条用复数变体**:同一条目写 `count_one` 与 `count_other` 两个键,取值时参数名必须为 `count`,例如 `m['home:index.count']({ count: posts.length })`;变体缺失时取词回退为原始 key 字符串,故两个语言文件必须键集合一致
+- `messages/*.json5` 必须保持 **JSON 兼容写法**(双引号、无尾逗号、不写注释):paraglide 编译器按严格 JSON 解析,无引号键/尾逗号/单引号会直接编译失败
- 修改词表后需重新编译生成 `src/lib/paraglide` 产物:`pnpm --filter @myblog/web exec paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide`,等价入口为 `pnpm --filter @myblog/web run generate:i18n`(`vite dev`/`build` 亦会自动触发)
## 部署指南
From a7581b136ffcd8de2e5e111301be425cc8ee6b60 Mon Sep 17 00:00:00 2001
From: idleRain
Date: Wed, 14 Oct 2026 17:29:18 +0800
Subject: [PATCH 3/7] =?UTF-8?q?feat(i18n):=20=E6=96=87=E7=AB=A0=E5=9F=9F?=
=?UTF-8?q?=E6=95=B4=E9=9D=A2=E6=8E=A5=E5=85=A5=E8=AF=8D=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
博客目录、文章详情、归档三页与 article 组件目录的文案改经词表取词,含两个 load 的加载失败文案。
新增 blog namespace(中英各 38 条)并注册到 project.inlang/settings.json。
跨面同文上收至 ui:篇数计数、创刊空态、返回首页引导,首页组件同步改用,不在各面重复登记。
债务登记同步:frontend 第 7 条基线更新为 21 个已接入文件,补记共享词上收与拆句取词两条约定。
---
apps/web/messages/en/blog.json5 | 52 +++++++++++++++++++
apps/web/messages/en/home.json5 | 3 --
apps/web/messages/en/ui.json5 | 8 ++-
apps/web/messages/zh/blog.json5 | 52 +++++++++++++++++++
apps/web/messages/zh/home.json5 | 3 --
apps/web/messages/zh/ui.json5 | 8 ++-
apps/web/project.inlang/settings.json | 3 +-
.../components/article/ArchiveTimeline.svelte | 10 +++-
.../components/article/ArticleActions.svelte | 11 ++--
.../article/ArticleIndexList.svelte | 4 +-
.../components/article/PaginationNav.svelte | 14 ++---
.../components/home/PostIndexSection.svelte | 4 +-
.../src/routes/(app)/archives/+page.svelte | 19 ++++---
apps/web/src/routes/(app)/archives/+page.ts | 3 +-
apps/web/src/routes/(app)/blog/+page.svelte | 39 ++++++++------
apps/web/src/routes/(app)/blog/+page.ts | 3 +-
.../src/routes/(app)/blog/[slug]/+page.svelte | 21 +++++---
docs/debt/frontend.md | 6 +--
docs/development.md | 11 ++--
19 files changed, 208 insertions(+), 66 deletions(-)
create mode 100644 apps/web/messages/en/blog.json5
create mode 100644 apps/web/messages/zh/blog.json5
diff --git a/apps/web/messages/en/blog.json5 b/apps/web/messages/en/blog.json5
new file mode 100644
index 0000000..f38bfa1
--- /dev/null
+++ b/apps/web/messages/en/blog.json5
@@ -0,0 +1,52 @@
+{
+ "list": {
+ "title": "{{site}} - Post index",
+ "description": "The index of every post, ordered by publication time, with keyword search and paging.",
+ "eyebrow": "Journal · All issues",
+ "heading": "Post index",
+ "resultCount_one": "“{{search}}” · {{count}} result",
+ "resultCount_other": "“{{search}}” · {{count}} results",
+ "searchLabel": "Search posts",
+ "searchPlaceholder": "Search titles and body text…",
+ "searchSubmit": "Search",
+ "searchEmpty": "No posts found for “{{search}}”.",
+ "searchEmptyBefore": "Try another keyword, or",
+ "searchEmptyClear": "clear the search",
+ "searchEmptyAfter": "to browse every issue."
+ },
+ "detail": {
+ "title": "{{title}} - {{site}}",
+ "eyebrow": "Journal · Post",
+ "commentsClosed": "Comments are closed for this post.",
+ "backToIndex": "← Back to the index"
+ },
+ "archives": {
+ "title": "{{site}} - Archives",
+ "description": "The chronological archive of every post, arranged by year and month.",
+ "eyebrow": "Chronicle · Archives",
+ "heading": "Archives",
+ "orderNote": "Arranged by year",
+ "emptyTitle": "The timeline awaits its first posts.",
+ "yearCount_one": "{{count}} article",
+ "yearCount_other": "{{count}} articles",
+ "monthLine": "Month {{month}} · {{date}}"
+ },
+ "actions": {
+ "signInRequired": "Sign in to join the conversation",
+ "failed": "Something went wrong, please try again later",
+ "liked": "Liked",
+ "like": "Like",
+ "bookmarked": "Saved",
+ "bookmark": "Save"
+ },
+ "pagination": {
+ "label": "Pagination",
+ "previous": "← Previous",
+ "next": "Next →",
+ "position": "Page {{current}} / {{total}}"
+ },
+ "error": {
+ "listFailed": "Failed to load the post list, please try again later",
+ "archivesFailed": "Failed to load the archive data, please try again later"
+ }
+}
diff --git a/apps/web/messages/en/home.json5 b/apps/web/messages/en/home.json5
index 71043cd..30e47d6 100644
--- a/apps/web/messages/en/home.json5
+++ b/apps/web/messages/en/home.json5
@@ -24,9 +24,6 @@
},
"index": {
"title": "Recent posts",
- "count_one": "{{count}} post · continuously updated",
- "count_other": "{{count}} posts · continuously updated",
- "emptyTitle": "The inaugural issue is in preparation, posts will follow soon.",
"emptyNote": "You can browse the layout and the site introduction in the meantime, or wait for updates on the archive page.",
"viewAll": "View all posts"
},
diff --git a/apps/web/messages/en/ui.json5 b/apps/web/messages/en/ui.json5
index 3e1c088..a0aba08 100644
--- a/apps/web/messages/en/ui.json5
+++ b/apps/web/messages/en/ui.json5
@@ -16,7 +16,13 @@
"minutesRead": "{{count}} min read",
"minutesReadApprox": "about {{count}} min",
"views_one": "{{count}} view",
- "views_other": "{{count}} views"
+ "views_other": "{{count}} views",
+ "postCount_one": "{{count}} post · continuously updated",
+ "postCount_other": "{{count}} posts · continuously updated"
+ },
+ "empty": {
+ "inPreparation": "The inaugural issue is in preparation, posts will follow soon.",
+ "backHome": "You can head back to the home page to browse the layout and the site introduction."
},
"button": {
"save": "Save",
diff --git a/apps/web/messages/zh/blog.json5 b/apps/web/messages/zh/blog.json5
new file mode 100644
index 0000000..c1db922
--- /dev/null
+++ b/apps/web/messages/zh/blog.json5
@@ -0,0 +1,52 @@
+{
+ "list": {
+ "title": "{{site}} - 博客目录",
+ "description": "全部文章的目录页,按发布时间编排,支持关键词检索与翻页浏览。",
+ "eyebrow": "手记 · 全部刊目",
+ "heading": "博客目录",
+ "resultCount_one": "检索「{{search}}」· {{count}} 篇结果",
+ "resultCount_other": "检索「{{search}}」· {{count}} 篇结果",
+ "searchLabel": "搜索文章",
+ "searchPlaceholder": "检索标题与正文关键词…",
+ "searchSubmit": "检索",
+ "searchEmpty": "未检索到与「{{search}}」相关的文章。",
+ "searchEmptyBefore": "可以更换关键词重试,或",
+ "searchEmptyClear": "清除检索",
+ "searchEmptyAfter": "浏览全部刊目。"
+ },
+ "detail": {
+ "title": "{{title}} - {{site}}",
+ "eyebrow": "手记 · 文章",
+ "commentsClosed": "这篇文章已关闭评论。",
+ "backToIndex": "← 返回目录"
+ },
+ "archives": {
+ "title": "{{site}} - 归档",
+ "description": "全部文章的编年归档,按年份与月份编排。",
+ "eyebrow": "编年 · Archives",
+ "heading": "归档",
+ "orderNote": "按年份编排",
+ "emptyTitle": "时间线正在等待第一批文章。",
+ "yearCount_one": "共 {{count}} 篇文章",
+ "yearCount_other": "共 {{count}} 篇文章",
+ "monthLine": "{{month}} 月 · {{date}}"
+ },
+ "actions": {
+ "signInRequired": "登录后即可参与互动",
+ "failed": "操作失败,请稍后重试",
+ "liked": "已点赞",
+ "like": "点赞",
+ "bookmarked": "已收藏",
+ "bookmark": "收藏"
+ },
+ "pagination": {
+ "label": "分页导航",
+ "previous": "← 上一页",
+ "next": "下一页 →",
+ "position": "第 {{current}} / {{total}} 页"
+ },
+ "error": {
+ "listFailed": "文章列表加载失败,请稍后重试",
+ "archivesFailed": "归档数据加载失败,请稍后重试"
+ }
+}
diff --git a/apps/web/messages/zh/home.json5 b/apps/web/messages/zh/home.json5
index b03c72d..2d8be9a 100644
--- a/apps/web/messages/zh/home.json5
+++ b/apps/web/messages/zh/home.json5
@@ -24,9 +24,6 @@
},
"index": {
"title": "近期文章",
- "count_one": "共 {{count}} 篇 · 持续更新",
- "count_other": "共 {{count}} 篇 · 持续更新",
- "emptyTitle": "创刊号正在筹备中,文章即将发布。",
"emptyNote": "可以先浏览版面与站点介绍,或前往归档页等待更新。",
"viewAll": "查看全部文章"
},
diff --git a/apps/web/messages/zh/ui.json5 b/apps/web/messages/zh/ui.json5
index b0531b6..55f5763 100644
--- a/apps/web/messages/zh/ui.json5
+++ b/apps/web/messages/zh/ui.json5
@@ -16,7 +16,13 @@
"minutesRead": "阅读 {{count}} 分钟",
"minutesReadApprox": "约 {{count}} 分钟",
"views_one": "{{count}} 次浏览",
- "views_other": "{{count}} 次浏览"
+ "views_other": "{{count}} 次浏览",
+ "postCount_one": "共 {{count}} 篇 · 持续更新",
+ "postCount_other": "共 {{count}} 篇 · 持续更新"
+ },
+ "empty": {
+ "inPreparation": "创刊号正在筹备中,文章即将发布。",
+ "backHome": "可以先回到首页浏览版面与站点介绍。"
},
"button": {
"save": "保存",
diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json
index 0318c91..f6b93ea 100644
--- a/apps/web/project.inlang/settings.json
+++ b/apps/web/project.inlang/settings.json
@@ -9,7 +9,8 @@
"common": "./messages/{locale}/common.json5",
"ui": "./messages/{locale}/ui.json5",
"auth": "./messages/{locale}/auth.json5",
- "home": "./messages/{locale}/home.json5"
+ "home": "./messages/{locale}/home.json5",
+ "blog": "./messages/{locale}/blog.json5"
}
},
"baseLocale": "zh",
diff --git a/apps/web/src/lib/components/article/ArchiveTimeline.svelte b/apps/web/src/lib/components/article/ArchiveTimeline.svelte
index 33b2ea7..f27cb0a 100644
--- a/apps/web/src/lib/components/article/ArchiveTimeline.svelte
+++ b/apps/web/src/lib/components/article/ArchiveTimeline.svelte
@@ -3,6 +3,7 @@ import type { ArticleArchiveYear } from '@myblog/api/modules/article/types'
import { gsap, MOTION } from '$lib/motion/gsap-setup'
import { formatDate } from '$lib/utils/format-date'
import { scrollReveal } from '$lib/motion/reveal'
+import { m } from '$i18n'
// 归档时间线属性:groups 为按年份倒序的归档分组。
interface Props {
@@ -54,7 +55,9 @@ $effect(() => {
@@ -75,7 +78,10 @@ $effect(() => {
aria-hidden="true"
>
- {month.month} 月 · {formatDate(article.publishedAt ?? article.createdAt)}
+ {m['blog:archives.monthLine']({
+ month: month.month,
+ date: formatDate(article.publishedAt ?? article.createdAt)
+ })}
@@ -92,7 +97,9 @@ $effect(() => {
{:else}
-
这篇文章已关闭评论。
+
+ {m['blog:detail.commentsClosed']()}
+
{/if}
@@ -102,7 +109,7 @@ $effect(() => {
href="/blog"
class="group inline-flex items-center gap-2 text-sm font-bold text-signal underline-offset-4 hover:underline"
>
- ← 返回目录
+ {m['blog:detail.backToIndex']()}
diff --git a/docs/debt/frontend.md b/docs/debt/frontend.md
index c6021e7..7728576 100644
--- a/docs/debt/frontend.md
+++ b/docs/debt/frontend.md
@@ -55,9 +55,9 @@
## 7. web 界面多语言局部接入
- **状态**:推进中,分批接入。
-- **基线**:已接入面 **12** 个文件——Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo 页,以及**首页整面**:`(app)/+page.svelte`(SEO 与年轮预览)、`(app)/+page.ts`(加载失败文案)与 `lib/components/home/` 下 HeroSection、PostIndexSection、FeaturedStory、BackToTop 四个组件。Header 的站名与作者身份已并入 `ui` 共享词条(`ui:site.name`、`ui:author.*`、`ui:brand.github`、`ui:meta.*`),页面标题不再引用中文站名常量。其余页面文案仍硬编码中文,en 模式下界面为混合语言。
-- **词表约定**:按面拆分为独立 namespace 并在 `project.inlang/settings.json` 的 `pathPattern` 注册,`ui` 只承载跨面 chrome 与共享词;插值必须用 i18next 双花括号 `{{param}}`,单花括号会被当作字面量原样输出;计数词条写 `_one`/`_other` 两个变体,参数名必须为 `count` 才参与 `Intl.PluralRules` 选择,变体缺失时取词回退为原始 key 字符串;词表必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败)。
-- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(当前 12 个文件,逐批递增);`pnpm --filter @myblog/web run generate:i18n` 后核对 `messages/{zh,en}` 各 namespace 的键集合与条数一致(当前 ui 74 / home 40 / auth 7 / common 4)。
+- **基线**:已接入面 **21** 个文件——Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo 页,以及**首页整面**(`(app)/+page.svelte`、`(app)/+page.ts` 与 `lib/components/home/` 下 HeroSection、PostIndexSection、FeaturedStory、BackToTop)与**文章域整面**(`(app)/blog/+page.svelte`、`(app)/blog/+page.ts`、`(app)/blog/[slug]/+page.svelte`、`(app)/archives/+page.svelte`、`(app)/archives/+page.ts` 与 `lib/components/article/` 下 ArticleActions、ArticleIndexList、ArchiveTimeline、PaginationNav;ArticleListSkeleton 与 article 桶文件无用户可见文案,不在此列)。跨面共享词收敛在 `ui`(`ui:site.name`、`ui:author.*`、`ui:brand.github`、`ui:meta.*`、`ui:empty.*`),页面标题不再引用中文站名常量。其余页面文案仍硬编码中文,en 模式下界面为混合语言。
+- **词表约定**:按面拆分为独立 namespace 并在 `project.inlang/settings.json` 的 `pathPattern` 注册,`ui` 只承载跨面 chrome 与共享词;同一文案出现在两个面时必须上收到 `ui`,不在各面重复登记;插值必须用 i18next 双花括号 `{{param}}`,单花括号会被当作字面量原样输出;计数词条写 `_one`/`_other` 两个变体,参数名必须为 `count` 才参与 `Intl.PluralRules` 选择,变体缺失时取词回退为原始 key 字符串;词表必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败),故 `apps/web/messages/` 已列入 `.prettierignore`。
+- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(当前 21 个文件,逐批递增且只增不减);`pnpm --filter @myblog/web run generate:i18n` 后核对 `messages/{zh,en}` 各 namespace 的键集合与条数一致(当前 ui 78 / blog 38 / home 37 / auth 7 / common 4)。
- **红线**:已接入文件禁止回退硬编码,不得在已接入文件里新增中文字面量;新增用户可见文案优先经 `m.*` 取词,页面文案进本面 namespace 不塞回 `ui`;其余页面待页面大变动后分批推进。
## 8. 字典页窄屏交互与工具栏布局遗留
diff --git a/docs/development.md b/docs/development.md
index 134b0d5..fc5a001 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -547,11 +547,12 @@ const updated = await UserAPI.updateUser({ id: user.id, username: 'new-name', em
#### 5. 界面多语言(仅 apps/web)
-- 用户可见文案经 `$i18n` 的 `m[':']()` 取词;接入现状与红线见 [`debt/frontend.md`](./debt/frontend.md) 第 7 条(Header/Footer/错误页/首页已接入,其余页面待页面大变动后分批,已接入文件禁止回退硬编码)
-- **namespace 按面拆分**:`ui` 只承载跨面 chrome 与共享词(站名、作者身份、品牌名、通用元信息),页面文案进各自面的 namespace;新增 namespace 须在 `apps/web/project.inlang/settings.json` 的 `plugin.inlang.i18next.pathPattern` 注册,并在 `messages/zh` 与 `messages/en` 各建同名文件
-- **插值用双花括号**:`{{param}}` 是 i18next 语法,取词写作 `m['home:seo.title']({ site })`;写成单花括号 `{param}` 会被当作字面量原样输出,生成的取词函数也不会声明该入参。词条首尾的空格具有语义,英文词条常以词尾空格衔接相邻的强调节点,不手工去除
-- **计数词条用复数变体**:同一条目写 `count_one` 与 `count_other` 两个键,取值时参数名必须为 `count`,例如 `m['home:index.count']({ count: posts.length })`;变体缺失时取词回退为原始 key 字符串,故两个语言文件必须键集合一致
-- `messages/*.json5` 必须保持 **JSON 兼容写法**(双引号、无尾逗号、不写注释):paraglide 编译器按严格 JSON 解析,无引号键/尾逗号/单引号会直接编译失败
+- 用户可见文案经 `$i18n` 的 `m[':']()` 取词;已接入面清单与红线见 [`debt/frontend.md`](./debt/frontend.md) 第 7 条(已接入文件禁止回退硬编码)
+- **namespace 按面拆分**:`ui` 只承载跨面 chrome 与共享词(站名、作者身份、品牌名、通用元信息、共享空状态),页面文案进各自面的 namespace;同一文案出现在两个面时必须上收到 `ui`,不在各面重复登记;新增 namespace 须在 `apps/web/project.inlang/settings.json` 的 `plugin.inlang.i18next.pathPattern` 注册,并在 `messages/zh` 与 `messages/en` 各建同名文件
+- **插值用双花括号**:`{{param}}` 是 i18next 语法,取词写作 `m['blog:list.title']({ site })`;写成单花括号 `{param}` 会被当作字面量原样输出,生成的取词函数也不会声明该入参。词条首尾的空格具有语义,英文词条常以词尾空格衔接相邻的强调节点,不手工去除
+- **计数词条用复数变体**:同一条目写 `count_one` 与 `count_other` 两个键,取值时参数名必须为 `count`,例如 `m['ui:meta.postCount']({ count: posts.length })`;变体缺失时取词回退为原始 key 字符串,故两个语言文件必须键集合一致
+- **句子被节点切开时按片段取词**:完整句子中间嵌链接或强调节点时,拆成 `…Before` / 链接文案 / `…After` 多条词条,语序由词条内容决定,不把 HTML 写进词条
+- `messages/*.json5` 必须保持 **JSON 兼容写法**(双引号、无尾逗号、不写注释):paraglide 编译器按严格 JSON 解析,无引号键/尾逗号/单引号会直接编译失败;`apps/web/messages/` 已列入 `.prettierignore`,因为 prettier 的 json5 解析器会把键改写为无引号形式,直接导致编译失败
- 修改词表后需重新编译生成 `src/lib/paraglide` 产物:`pnpm --filter @myblog/web exec paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide`,等价入口为 `pnpm --filter @myblog/web run generate:i18n`(`vite dev`/`build` 亦会自动触发)
## 部署指南
From 72ace6afb68ecbecd3da3ae38a7afd3aa1477d93 Mon Sep 17 00:00:00 2001
From: idleRain
Date: Wed, 14 Oct 2026 17:41:38 +0800
Subject: [PATCH 4/7] =?UTF-8?q?feat(i18n):=20=E7=94=A8=E6=88=B7=E5=9F=9F?=
=?UTF-8?q?=E6=95=B4=E9=9D=A2=E6=8E=A5=E5=85=A5=E8=AF=8D=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
登录、个人资料、我的收藏三页与两个服务端 load、关注按钮、评论区文案改经词表取词。
新增 account 与 comment 两个 namespace,跨面同文(操作失败、提交中、会话过期)上收至 ui。
补 vitest 的 $i18n 别名,使引用取词模块的单测不再因别名缺失而解析失败。
债务登记同步:frontend 第 7 条基线更新为 29 个已接入文件;architecture 第 8 条扩至共享包内置文案。
---
apps/web/messages/en/account.json5 | 71 ++++++++++++++++
apps/web/messages/en/blog.json5 | 1 -
apps/web/messages/en/comment.json5 | 18 +++++
apps/web/messages/en/ui.json5 | 8 +-
apps/web/messages/zh/account.json5 | 71 ++++++++++++++++
apps/web/messages/zh/blog.json5 | 1 -
apps/web/messages/zh/comment.json5 | 18 +++++
apps/web/messages/zh/ui.json5 | 8 +-
apps/web/project.inlang/settings.json | 4 +-
.../components/article/ArticleActions.svelte | 4 +-
.../components/comment/CommentSection.svelte | 35 ++++----
.../layout/FriendlyLinkDialog.svelte | 2 +-
.../lib/components/user/FollowButton.svelte | 11 +--
apps/web/src/lib/service/index.ts | 3 +-
.../routes/(app)/favorites/+page.server.ts | 6 +-
.../src/routes/(app)/favorites/+page.svelte | 21 +++--
apps/web/src/routes/(app)/login/+page.svelte | 43 +++++-----
.../src/routes/(app)/profile/+page.server.ts | 6 +-
.../web/src/routes/(app)/profile/+page.svelte | 81 +++++++++++--------
apps/web/vitest.config.ts | 4 +-
docs/architecture-rules.md | 4 +-
docs/debt/architecture.md | 10 +--
docs/debt/frontend.md | 6 +-
docs/development.md | 2 +
24 files changed, 330 insertions(+), 108 deletions(-)
create mode 100644 apps/web/messages/en/account.json5
create mode 100644 apps/web/messages/en/comment.json5
create mode 100644 apps/web/messages/zh/account.json5
create mode 100644 apps/web/messages/zh/comment.json5
diff --git a/apps/web/messages/en/account.json5 b/apps/web/messages/en/account.json5
new file mode 100644
index 0000000..04d0f0d
--- /dev/null
+++ b/apps/web/messages/en/account.json5
@@ -0,0 +1,71 @@
+{
+ "login": {
+ "title": "{{site}} - Sign in",
+ "description": "Sign in to comment, like, save posts and follow authors.",
+ "eyebrow": "Portal · Auth",
+ "heading": "Welcome back",
+ "usernameLabel": "Username",
+ "usernamePlaceholder": "Enter your username",
+ "passwordLabel": "Password",
+ "passwordPlaceholder": "Enter your password",
+ "showPassword": "Show password",
+ "hidePassword": "Hide password",
+ "submit": "Sign in",
+ "submitting": "Signing in…",
+ "guestNote": "Without an account you can still comment as a guest, or contact the site owner to have one created.",
+ "validationFailed": "Enter your username and password",
+ "failed": "Sign-in failed, please check your username and password",
+ "sessionFailed": "Failed to establish the session, please try again",
+ "success": "Signed in",
+ "networkFailed": "Network error, please try again later"
+ },
+ "profile": {
+ "title": "{{site}} - Profile",
+ "description": "Maintain the signed-in user's profile: display name, avatar, bio and password.",
+ "eyebrow": "Profile · Settings",
+ "heading": "Profile",
+ "basicsTitle": "Basic details",
+ "basicsNote": "Your display name and bio appear on comments and your author page.",
+ "nicknameLabel": "Display name",
+ "nicknamePlaceholder": "Your display name",
+ "avatarLabel": "Avatar URL",
+ "urlPlaceholder": "https://…",
+ "bioLabel": "Bio",
+ "bioPlaceholder": "One line about yourself",
+ "websiteLabel": "Website",
+ "saveSubmit": "Save profile",
+ "saveSubmitting": "Saving…",
+ "saveFailed": "Failed to save the profile, please try again later",
+ "saveSuccess": "Profile saved",
+ "passwordTitle": "Change password",
+ "passwordRule": "{{min}}-{{max}} characters, including both letters and digits.",
+ "currentPasswordLabel": "Current password",
+ "currentPasswordPlaceholder": "Enter your current password",
+ "newPasswordLabel": "New password",
+ "newPasswordPlaceholder": "Enter a new password",
+ "confirmPasswordLabel": "Confirm new password",
+ "confirmPasswordPlaceholder": "Repeat the new password",
+ "passwordMismatch": "The two new passwords do not match",
+ "passwordSubmit": "Change password",
+ "passwordFailed": "Failed to change the password, please try again later",
+ "passwordSuccess": "Password changed, please sign in again with the new password",
+ "loadFailed": "Failed to load the profile, please try again later"
+ },
+ "favorites": {
+ "title": "{{site}} - Favorites",
+ "description": "Posts saved by the signed-in user.",
+ "eyebrow": "Favorites · Bookmarks",
+ "heading": "Favorites",
+ "count_one": "{{count}} saved post",
+ "count_other": "{{count}} saved posts",
+ "emptyTitle": "No saved posts yet.",
+ "emptyNote": "Use the save button on a post to collect it here.",
+ "loadFailed": "Failed to load the saved posts, please try again later"
+ },
+ "follow": {
+ "signInRequired": "Sign in to follow this author",
+ "busy": "Working…",
+ "following": "Following",
+ "follow": "Follow"
+ }
+}
diff --git a/apps/web/messages/en/blog.json5 b/apps/web/messages/en/blog.json5
index f38bfa1..0bae6bf 100644
--- a/apps/web/messages/en/blog.json5
+++ b/apps/web/messages/en/blog.json5
@@ -33,7 +33,6 @@
},
"actions": {
"signInRequired": "Sign in to join the conversation",
- "failed": "Something went wrong, please try again later",
"liked": "Liked",
"like": "Like",
"bookmarked": "Saved",
diff --git a/apps/web/messages/en/comment.json5 b/apps/web/messages/en/comment.json5
new file mode 100644
index 0000000..8dd076c
--- /dev/null
+++ b/apps/web/messages/en/comment.json5
@@ -0,0 +1,18 @@
+{
+ "title": "Comments",
+ "count_one": "{{count}} comment",
+ "count_other": "{{count}} comments",
+ "nameLabel": "Name",
+ "namePlaceholder": "Name *",
+ "emailLabel": "Email",
+ "emailPlaceholder": "Email (not published)",
+ "contentLabel": "Comment",
+ "contentPlaceholder": "Say something",
+ "guestContentPlaceholder": "Say something as a guest",
+ "moderationNote": "Comments are published after review",
+ "submit": "Post comment",
+ "empty": "No comments yet. Be the first to say something.",
+ "loadMore": "Load more comments",
+ "submitFailed": "Failed to submit the comment, please try again later",
+ "submitSuccess": "Comment submitted, it will be published after review"
+}
diff --git a/apps/web/messages/en/ui.json5 b/apps/web/messages/en/ui.json5
index a0aba08..fb1750d 100644
--- a/apps/web/messages/en/ui.json5
+++ b/apps/web/messages/en/ui.json5
@@ -24,6 +24,13 @@
"inPreparation": "The inaugural issue is in preparation, posts will follow soon.",
"backHome": "You can head back to the home page to browse the layout and the site introduction."
},
+ "action": {
+ "failed": "Something went wrong, please try again later",
+ "submitting": "Submitting…"
+ },
+ "session": {
+ "expired": "Your session has expired, please sign in again"
+ },
"button": {
"save": "Save",
"cancel": "Cancel",
@@ -92,7 +99,6 @@
"contactEmail": "Contact email",
"contactEmailPlaceholder": "Used to receive the review result",
"submit": "Submit application",
- "submitting": "Submitting…",
"applySubmitted": "Application submitted, awaiting review",
"submitFailed": "Failed to submit the application, please try again later"
},
diff --git a/apps/web/messages/zh/account.json5 b/apps/web/messages/zh/account.json5
new file mode 100644
index 0000000..725e481
--- /dev/null
+++ b/apps/web/messages/zh/account.json5
@@ -0,0 +1,71 @@
+{
+ "login": {
+ "title": "{{site}} - 登录",
+ "description": "登录后即可参与评论、点赞、收藏与关注等互动。",
+ "eyebrow": "门户 · Auth",
+ "heading": "欢迎回来",
+ "usernameLabel": "用户名",
+ "usernamePlaceholder": "请输入用户名",
+ "passwordLabel": "密码",
+ "passwordPlaceholder": "请输入密码",
+ "showPassword": "显示密码",
+ "hidePassword": "隐藏密码",
+ "submit": "登录",
+ "submitting": "登录中…",
+ "guestNote": "尚无账户时可通过评论区以访客身份留言,或联系站长开通。",
+ "validationFailed": "请输入用户名和密码",
+ "failed": "登录失败,请检查用户名和密码",
+ "sessionFailed": "会话建立失败,请重试",
+ "success": "登录成功",
+ "networkFailed": "网络错误,请稍后重试"
+ },
+ "profile": {
+ "title": "{{site}} - 个人资料",
+ "description": "当前登录用户的资料维护页,支持修改昵称、头像、简介与登录密码。",
+ "eyebrow": "资料 · Profile",
+ "heading": "个人资料",
+ "basicsTitle": "基础资料",
+ "basicsNote": "昵称与简介会展示在评论与作者主页。",
+ "nicknameLabel": "昵称",
+ "nicknamePlaceholder": "展示昵称",
+ "avatarLabel": "头像地址",
+ "urlPlaceholder": "https://…",
+ "bioLabel": "个人简介",
+ "bioPlaceholder": "一句话介绍自己",
+ "websiteLabel": "个人网站",
+ "saveSubmit": "保存资料",
+ "saveSubmitting": "保存中…",
+ "saveFailed": "资料保存失败,请稍后重试",
+ "saveSuccess": "资料已保存",
+ "passwordTitle": "修改密码",
+ "passwordRule": "长度 {{min}}-{{max}} 位,需同时包含字母和数字。",
+ "currentPasswordLabel": "当前密码",
+ "currentPasswordPlaceholder": "请输入当前密码",
+ "newPasswordLabel": "新密码",
+ "newPasswordPlaceholder": "请输入新密码",
+ "confirmPasswordLabel": "确认新密码",
+ "confirmPasswordPlaceholder": "请再次输入新密码",
+ "passwordMismatch": "两次输入的新密码不一致",
+ "passwordSubmit": "修改密码",
+ "passwordFailed": "密码修改失败,请稍后重试",
+ "passwordSuccess": "密码修改成功,请使用新密码重新登录",
+ "loadFailed": "资料加载失败,请稍后重试"
+ },
+ "favorites": {
+ "title": "{{site}} - 我的收藏",
+ "description": "当前登录用户收藏的文章列表。",
+ "eyebrow": "收藏 · Bookmarks",
+ "heading": "我的收藏",
+ "count_one": "共 {{count}} 篇",
+ "count_other": "共 {{count}} 篇",
+ "emptyTitle": "还没有收藏任何文章。",
+ "emptyNote": "在文章页点击收藏按钮,即可在这里找到它们。",
+ "loadFailed": "收藏列表加载失败,请稍后重试"
+ },
+ "follow": {
+ "signInRequired": "登录后即可关注作者",
+ "busy": "处理中…",
+ "following": "已关注",
+ "follow": "关注"
+ }
+}
diff --git a/apps/web/messages/zh/blog.json5 b/apps/web/messages/zh/blog.json5
index c1db922..516367a 100644
--- a/apps/web/messages/zh/blog.json5
+++ b/apps/web/messages/zh/blog.json5
@@ -33,7 +33,6 @@
},
"actions": {
"signInRequired": "登录后即可参与互动",
- "failed": "操作失败,请稍后重试",
"liked": "已点赞",
"like": "点赞",
"bookmarked": "已收藏",
diff --git a/apps/web/messages/zh/comment.json5 b/apps/web/messages/zh/comment.json5
new file mode 100644
index 0000000..c9f1932
--- /dev/null
+++ b/apps/web/messages/zh/comment.json5
@@ -0,0 +1,18 @@
+{
+ "title": "评论",
+ "count_one": "共 {{count}} 条",
+ "count_other": "共 {{count}} 条",
+ "nameLabel": "姓名",
+ "namePlaceholder": "姓名 *",
+ "emailLabel": "邮箱",
+ "emailPlaceholder": "邮箱(不公开)",
+ "contentLabel": "评论内容",
+ "contentPlaceholder": "说点什么吧",
+ "guestContentPlaceholder": "以访客身份说点什么吧",
+ "moderationNote": "评论提交后需经审核才会展示",
+ "submit": "发表评论",
+ "empty": "还没有评论,来说点什么吧。",
+ "loadMore": "查看更多评论",
+ "submitFailed": "评论提交失败,请稍后重试",
+ "submitSuccess": "评论已提交,审核通过后展示"
+}
diff --git a/apps/web/messages/zh/ui.json5 b/apps/web/messages/zh/ui.json5
index 55f5763..4e2457b 100644
--- a/apps/web/messages/zh/ui.json5
+++ b/apps/web/messages/zh/ui.json5
@@ -24,6 +24,13 @@
"inPreparation": "创刊号正在筹备中,文章即将发布。",
"backHome": "可以先回到首页浏览版面与站点介绍。"
},
+ "action": {
+ "failed": "操作失败,请稍后重试",
+ "submitting": "提交中…"
+ },
+ "session": {
+ "expired": "登录已过期,请重新登录"
+ },
"button": {
"save": "保存",
"cancel": "取消",
@@ -92,7 +99,6 @@
"contactEmail": "联系邮箱",
"contactEmailPlaceholder": "用于接收审核结果",
"submit": "提交申请",
- "submitting": "提交中…",
"applySubmitted": "申请已提交,等待站长审核",
"submitFailed": "申请提交失败,请稍后重试"
},
diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json
index f6b93ea..7cd5612 100644
--- a/apps/web/project.inlang/settings.json
+++ b/apps/web/project.inlang/settings.json
@@ -10,7 +10,9 @@
"ui": "./messages/{locale}/ui.json5",
"auth": "./messages/{locale}/auth.json5",
"home": "./messages/{locale}/home.json5",
- "blog": "./messages/{locale}/blog.json5"
+ "blog": "./messages/{locale}/blog.json5",
+ "account": "./messages/{locale}/account.json5",
+ "comment": "./messages/{locale}/comment.json5"
}
},
"baseLocale": "zh",
diff --git a/apps/web/src/lib/components/article/ArticleActions.svelte b/apps/web/src/lib/components/article/ArticleActions.svelte
index 99218ed..5261605 100644
--- a/apps/web/src/lib/components/article/ArticleActions.svelte
+++ b/apps/web/src/lib/components/article/ArticleActions.svelte
@@ -63,7 +63,7 @@ async function toggleLike() {
try {
const response = isLiked ? await ArticleAPI.unlike(articleId) : await ArticleAPI.like(articleId)
if (response.code !== RESPONSE_CODE_SUCCESS) {
- toast.error(response.message || m['blog:actions.failed']())
+ toast.error(response.message || m['ui:action.failed']())
return
}
isLiked = !isLiked
@@ -86,7 +86,7 @@ async function toggleBookmark() {
? await ArticleAPI.unbookmark(articleId)
: await ArticleAPI.bookmark(articleId)
if (response.code !== RESPONSE_CODE_SUCCESS) {
- toast.error(response.message || m['blog:actions.failed']())
+ toast.error(response.message || m['ui:action.failed']())
return
}
isBookmarked = !isBookmarked
diff --git a/apps/web/src/lib/components/comment/CommentSection.svelte b/apps/web/src/lib/components/comment/CommentSection.svelte
index 2896098..dbaa3f2 100644
--- a/apps/web/src/lib/components/comment/CommentSection.svelte
+++ b/apps/web/src/lib/components/comment/CommentSection.svelte
@@ -6,6 +6,7 @@ import { SvelteMap } from 'svelte/reactivity'
import { authStore } from '$lib/stores/auth'
import { toast } from 'svelte-sonner'
import { CommentAPI } from '$lib/api'
+import { m } from '$i18n'
// 评论内容的长度上限,与后端 binding 校验保持一致。
const COMMENT_MAX_LENGTH = 2000
@@ -138,11 +139,11 @@ async function handleSubmit(event: SubmitEvent) {
})
if (response.code !== RESPONSE_CODE_SUCCESS) {
- toast.error(response.message || '评论提交失败,请稍后重试')
+ toast.error(response.message || m['comment:submitFailed']())
return
}
- toast.success('评论已提交,审核通过后展示')
+ toast.success(m['comment:submitSuccess']())
content = ''
authorName = ''
authorEmail = ''
@@ -156,8 +157,10 @@ async function handleSubmit(event: SubmitEvent) {
评论
- 共 {total} 条 +{m['comment:title']()}
+ + {m['comment:count']({ count: total })} +评论提交后需经审核才会展示
++ {m['comment:moderationNote']()} +
还没有评论,来说点什么吧。
+{m['comment:empty']()}
@@ -257,7 +264,7 @@ async function handleSubmit(event: SubmitEvent) { onclick={loadMore} class="mt-8 py-2 text-sm font-bold text-signal underline-offset-4 hover:underline" > - 查看更多评论 + {m['comment:loadMore']()} {/if} {/if} diff --git a/apps/web/src/lib/components/layout/FriendlyLinkDialog.svelte b/apps/web/src/lib/components/layout/FriendlyLinkDialog.svelte index 0636360..2f54d4d 100644 --- a/apps/web/src/lib/components/layout/FriendlyLinkDialog.svelte +++ b/apps/web/src/lib/components/layout/FriendlyLinkDialog.svelte @@ -143,7 +143,7 @@ async function handleApply(event: SubmitEvent) { disabled={applying} class="mt-4 inline-flex w-full items-center justify-center bg-primary px-4 py-2.5 text-sm font-bold text-primary-foreground transition-[background-color,color,transform] duration-200 ease-(--ease-out-strong) hover:bg-signal hover:text-signal-foreground active:scale-[0.97] disabled:cursor-not-allowed disabled:opacity-60" > - {applying ? m['ui:linkDialog.submitting']() : m['ui:linkDialog.submit']()} + {applying ? m['ui:action.submitting']() : m['ui:linkDialog.submit']()} diff --git a/apps/web/src/lib/components/user/FollowButton.svelte b/apps/web/src/lib/components/user/FollowButton.svelte index ee702bb..b6b370c 100644 --- a/apps/web/src/lib/components/user/FollowButton.svelte +++ b/apps/web/src/lib/components/user/FollowButton.svelte @@ -3,6 +3,7 @@ import { authStore } from '$lib/stores/auth' import { goto } from '$app/navigation' import { toast } from 'svelte-sonner' import { FollowAPI } from '$lib/api' +import { m } from '$i18n' // 后端统一响应的成功业务码。 const SUCCESS_CODE = 200 @@ -48,7 +49,7 @@ async function refreshFollowing() { // 未登录时引导前往登录页。 function requireAuth() { - toast.info('登录后即可关注作者') + toast.info(m['account:follow.signInRequired']()) void goto('/login') } @@ -66,7 +67,7 @@ async function toggleFollow() { ? await FollowAPI.unfollow({ followingId: targetUserId }) : await FollowAPI.follow({ followingId: targetUserId }) if (response.code !== SUCCESS_CODE) { - toast.error(response.message || '操作失败,请稍后重试') + toast.error(response.message || m['ui:action.failed']()) return } isFollowing = !isFollowing @@ -85,10 +86,10 @@ async function toggleFollow() { : 'bg-primary text-primary-foreground hover:bg-signal hover:text-signal-foreground'}" > {#if busy} - 处理中… + {m['account:follow.busy']()} {:else if isFollowing} - 已关注 + {m['account:follow.following']()} {:else} - 关注 + {m['account:follow.follow']()} {/if} diff --git a/apps/web/src/lib/service/index.ts b/apps/web/src/lib/service/index.ts index 04adfa5..200a0db 100644 --- a/apps/web/src/lib/service/index.ts +++ b/apps/web/src/lib/service/index.ts @@ -7,6 +7,7 @@ import { authStore } from '$lib/stores/auth' import { browser } from '$app/environment' import { goto } from '$app/navigation' import { toast } from 'svelte-sonner' +import { m } from '$i18n' import ky from 'ky' const prefixUrl = import.meta.env.SSR @@ -54,7 +55,7 @@ const request = createHttpClient({ onAuthFailure: async message => { authStore.clearLocalState() if (browser) { - toast.error(message || '登录已过期,请重新登录') + toast.error(message || m['ui:session.expired']()) await goto('/login') } } diff --git a/apps/web/src/routes/(app)/favorites/+page.server.ts b/apps/web/src/routes/(app)/favorites/+page.server.ts index 3998a9d..b80b57e 100644 --- a/apps/web/src/routes/(app)/favorites/+page.server.ts +++ b/apps/web/src/routes/(app)/favorites/+page.server.ts @@ -2,6 +2,7 @@ import { fetchAuthenticated } from '$lib/service/ssr' import { error, redirect } from '@sveltejs/kit' import { createArticleAPI } from '@myblog/api' import type { PageServerLoad } from './$types' +import { m } from '$i18n' // 收藏列表每页数量,与其他目录页保持一致的版面节奏。 const FAVORITES_PAGE_SIZE = 12 @@ -9,9 +10,6 @@ const FAVORITES_PAGE_SIZE = 12 // 未登录或会话缺失时统一跳转登录页,由登录页承接身份建立。 const LOGIN_PATH = '/login' -// 收藏读取失败时的页面级提示,与既有客户端补拉的文案保持一致。 -const LOAD_FAILURE_MESSAGE = '收藏列表加载失败,请稍后重试' - /** * 收藏列表页在服务端取数。 * 会话 Cookie 由 fetchAuthenticated 注入请求,后端据此识别登录身份; @@ -33,7 +31,7 @@ export const load: PageServerLoad = async ({ request, url }) => { throw redirect(302, LOGIN_PATH) } if (result.status === 'failed') { - throw error(503, LOAD_FAILURE_MESSAGE) + throw error(503, m['account:favorites.loadFailed']()) } return { list: result.data, currentPage } diff --git a/apps/web/src/routes/(app)/favorites/+page.svelte b/apps/web/src/routes/(app)/favorites/+page.svelte index 5d20c24..55c3bdd 100644 --- a/apps/web/src/routes/(app)/favorites/+page.svelte +++ b/apps/web/src/routes/(app)/favorites/+page.svelte @@ -1,9 +1,9 @@
- 我的收藏 - {SITE_NAME_ZH}
-
+ {pageTitle}
+
@@ -41,12 +44,14 @@ const skeletonRows = $derived(Math.max(MIN_SKELETON_ROWS, articles.length))
{:else}
-
{/if}
diff --git a/apps/web/src/routes/(app)/login/+page.svelte b/apps/web/src/routes/(app)/login/+page.svelte
index c6e77b5..ad54be0 100644
--- a/apps/web/src/routes/(app)/login/+page.svelte
+++ b/apps/web/src/routes/(app)/login/+page.svelte
@@ -1,12 +1,12 @@
- 登录 - {SITE_NAME_ZH}
-
+ {pageTitle}
+
@@ -76,45 +79,49 @@ async function handleLogin(event: SubmitEvent) {
(initialProfile())
@@ -86,15 +89,15 @@ async function handleProfileSubmit(event: SubmitEvent) {
})
if (response.code !== RESPONSE_CODE_SUCCESS || !response.data) {
- toast.error(response.message || '资料保存失败,请稍后重试')
+ toast.error(response.message || m['account:profile.saveFailed']())
return
}
applyProfile(response.data)
authStore.updateUser(response.data)
- toast.success('资料已保存')
+ toast.success(m['account:profile.saveSuccess']())
} catch {
- toast.error('资料保存失败,请稍后重试')
+ toast.error(m['account:profile.saveFailed']())
} finally {
savingProfile = false
}
@@ -107,7 +110,7 @@ async function handlePasswordSubmit(event: SubmitEvent) {
if (savingPassword) return
if (newPassword !== confirmPassword) {
- toast.error('两次输入的新密码不一致')
+ toast.error(m['account:profile.passwordMismatch']())
return
}
@@ -115,15 +118,15 @@ async function handlePasswordSubmit(event: SubmitEvent) {
try {
const response = await UserAPI.changePassword({ oldPassword, newPassword })
if (response.code !== RESPONSE_CODE_SUCCESS) {
- toast.error(response.message || '密码修改失败,请稍后重试')
+ toast.error(response.message || m['account:profile.passwordFailed']())
return
}
- toast.success('密码修改成功,请使用新密码重新登录')
+ toast.success(m['account:profile.passwordSuccess']())
await authStore.logout(true)
void goto('/login')
} catch {
- toast.error('密码修改失败,请稍后重试')
+ toast.error(m['account:profile.passwordFailed']())
} finally {
savingPassword = false
}
@@ -131,11 +134,8 @@ async function handlePasswordSubmit(event: SubmitEvent) {
- 个人资料 - {SITE_NAME_ZH}
-
+ {pageTitle}
+
@@ -145,10 +145,10 @@ async function handlePasswordSubmit(event: SubmitEvent) {
diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.ts
index 8b97147..bb0fdb8 100644
--- a/apps/web/vitest.config.ts
+++ b/apps/web/vitest.config.ts
@@ -18,7 +18,9 @@ export default defineConfig({
// 与应用源码保持同一套别名,避免测试走另一条解析路径。
$lib: fileURLToPath(new URL('./src/lib', import.meta.url)),
'@': fileURLToPath(new URL('./src', import.meta.url)),
- $ui: fileURLToPath(new URL('../../packages/ui/src', import.meta.url))
+ $ui: fileURLToPath(new URL('../../packages/ui/src', import.meta.url)),
+ // 取词模块是 paraglide 编译产物,单测前需先执行 generate:i18n。
+ $i18n: fileURLToPath(new URL('./src/lib/paraglide/messages', import.meta.url))
}
},
test: {
diff --git a/docs/architecture-rules.md b/docs/architecture-rules.md
index 4b37088..b637f57 100644
--- a/docs/architecture-rules.md
+++ b/docs/architecture-rules.md
@@ -293,7 +293,7 @@ git grep -n "SetTrustedProxies" -- server
| 应用层影子类型层 | [`debt/architecture.md`](./debt/architecture.md) 第 5 条 | 禁止重新引入,类型一律来自 `@myblog/api` |
| follow 模块仅后端 | [`debt/architecture.md`](./debt/architecture.md) 第 6 条 | 关注数据仅经 service 域端点读写 |
| 业务错误未归哨兵导致分档退化为 500 | [`debt/architecture.md`](./debt/architecture.md) 第 7 条 | 新增业务错误必须包装哨兵并同步登记契约 |
-| 后端响应文案不随语言切换 | [`debt/architecture.md`](./debt/architecture.md) 第 8 条 | 前端后备文案禁止回退硬编码,落地前不得按错误码另建文案映射 |
+| 响应与共享包文案不随语言切换 | [`debt/architecture.md`](./debt/architecture.md) 第 8 条 | 前端后备文案禁止回退硬编码;packages 不得内置用户可见文案 |
| 两 app 基础设施逐字重复 | [`debt/frontend.md`](./debt/frontend.md) 第 1 条 | 修改任一必须同步另一份 |
| admin 认证工具三轨并行 | [`debt/frontend.md`](./debt/frontend.md) 第 2 条 | 禁止新增认证工具文件与双轨回退 |
| admin 胖组件 + onMount 取数 | [`debt/frontend.md`](./debt/frontend.md) 第 3 条 | 新页面禁用 onMount 取数;行数与取数口径均已清零,constants 不得引入图标库 |
@@ -323,7 +323,7 @@ git grep -n "SetTrustedProxies" -- server
| 阶段五 扩展点 | 后端 ContentRenderer 内容策略接口(当前 `pkg/markdown` 已直接承接 Markdown 渲染,策略接口化待做);web 业务页面已按"公开数据 SSR + 个性化数据客户端补拉"现状接入,token 迁 cookie 已完成 | — | 新文章类型 = 插入实现,非逐层打洞 |
| 阶段六 代理信任链收敛 | 引擎构造期接入信任链白名单;`NewRouter` 改为返回错误;配置校验拒绝覆盖全部地址的取值;补伪造转发头的四态用例 | 代理信任链未收敛导致 `ClientIP()` 可伪造(`docs/debt/security-runtime.md` 第 4 条) | ✅ 接线前实测三例失败且日志 `clientIp` 为伪造值;接线后伪造转发头不再影响 `ClientIP()` |
| 阶段七 依赖边口径订正 | 中间件在包内声明消费方窄接口,收敛对 repository 包的依赖;债务基线拆分为允许边与违例边,同步订正 §2.1、§2.3 与 CI 断言 | service/middleware/router import repository(`docs/debt/architecture.md` 第 1 条) | ✅ middleware 与 router 的违例 import 归零;查询参数留在 repository 经确认接受;CI 基线断言由 ≤13 改为 =0 |
-| 阶段八 界面多语言分批接入 | web 界面文案按面分批接入 paraglide 词表,词表按面拆 namespace 并固化插值与复数写法;每批同步登记债务基线与本节 | web 界面多语言局部接入(`docs/debt/frontend.md` 第 7 条)推进中;后端响应文案不随语言切换(`docs/debt/architecture.md` 第 8 条)待接入 | ✅ 已接入文件禁止回退硬编码;`git grep -ln "\$i18n" -- apps/web/src` 的命中面逐批递增且只增不减,各 namespace 中英键集合一致 |
+| 阶段八 界面多语言分批接入 | web 界面文案按面分批接入 paraglide 词表,词表按面拆 namespace 并固化插值与复数写法;每批同步登记债务基线与本节 | web 界面多语言局部接入(`docs/debt/frontend.md` 第 7 条)推进中;响应与共享包文案不随语言切换(`docs/debt/architecture.md` 第 8 条)待接入 | ✅ 已接入文件禁止回退硬编码;`git grep -ln "\$i18n" -- apps/web/src` 的命中面逐批递增且只增不减,各 namespace 中英键集合一致 |
---
diff --git a/docs/debt/architecture.md b/docs/debt/architecture.md
index 0c509ac..5bdcf62 100644
--- a/docs/debt/architecture.md
+++ b/docs/debt/architecture.md
@@ -56,9 +56,9 @@
应输出 0;分档一致性由 `go test ./internal/handler/ -run TestErrorMappingMatchesContract -count=1` 与 `pnpm run contract:check` 锚定。
- **红线**:新增业务校验失败、认证失败与资源未找到必须包装对应哨兵(`service.ErrUnauthenticated`、`service.ErrInvalidRequest`、`domain.ErrXxxNotFound` 等),并同步登记 `contracts/errors.yaml` 的 mapping 节与 `handler` 分档注册表;禁止以裸错误表达同类语义,禁止在模块内新增私有映射分支。
-## 8. 后端响应文案不随语言切换
+## 8. 响应与共享包文案不随语言切换
-- **状态**:推进中,随界面多语言分批接入推进。
-- **基线**:接口响应同时携带 `code` 与 `message`,前端 8 处以 `response.message || 后备文案` 直出后端字符串(`ArticleActions` 2、`CommentSection` 1、`FollowButton` 1、`login` 1、`profile` 2、`FriendlyLinkDialog` 1),其中 7 处后备仍为硬编码中文、仅 `FriendlyLinkDialog` 已接入词表。后端 `message` 是 service 与 domain 层哨兵错误的原始文本,经 `handler.HandleServiceError` 的 `response.Error(c, mapping.Code, err.Error())` 直出,无语言维度;`message` 命中时前端后备不生效,en 模式下提示仍为中文。`internal/middleware/language.go` 已把语言写入请求上下文,具备接入条件。
-- **验证命令**:`git grep -n "response.message" -- apps/web/src`(当前 9 处,含 `ssr.ts` 的管道传递);`git grep -n "err.Error()" -- server/internal/handler/error.go`(后端文案直出点,应为 1 处且无本地化分支)。
-- **红线**:前端后备文案禁止回退硬编码;前端若改为按错误码取词,须与 `contracts/errors.yaml` 的 mapping 节在同一变更窗口内同步,禁止另建与契约脱钩的映射表。
+- **状态**:推进中,前端后备侧已接入词表,后端侧与共享包侧未接入。
+- **基线**:接口响应同时携带 `code` 与 `message`,前端 8 处 `response.message || 后备文案` 的后备已全部经词表取词(`ArticleActions` 2、`CommentSection` 1、`FollowButton` 1、`login` 1、`profile` 2、`FriendlyLinkDialog` 1),另 1 处 `ssr.ts` 只做管道传递不直出。后端 `message` 是 service 与 domain 层哨兵错误的原始文本,经 `handler.HandleServiceError` 的 `response.Error(c, mapping.Code, err.Error())` 直出,无语言维度;`message` 命中时前端后备不生效,en 模式下提示仍为中文。共享包侧另有 4 处内置中文文案,即 `packages/http/src/client.ts` 的会话失效、认证失败与请求失败提示,以及 `packages/http/src/response.ts` 的消息空值降级,经 `auth.onAuthFailure` 与 `onError` 回调直出为 toast;packages 无法解析 `$i18n` 别名,该侧文案不能直接取词。`internal/middleware/language.go` 已把语言写入请求上下文,后端具备接入条件。
+- **验证命令**:`git grep -n "response.message" -- apps/web/src`(前端 9 处,含 `ssr.ts` 的管道传递);`git grep -n "err.Error()" -- server/internal/handler/error.go`(后端文案直出点,应为 1 处且无本地化分支);`git grep -n "登录已过期\|认证失败\|请求失败" -- packages`(共享包内置文案,应命中 `client.ts` 三处与 `response.ts` 一处)。
+- **红线**:前端后备文案禁止回退硬编码;前端若改为按错误码取词,须与 `contracts/errors.yaml` 的 mapping 节在同一变更窗口内同步,禁止另建与契约脱钩的映射表;packages 不得新增内置的用户可见文案,需要展示的提示一律由应用侧经回调注入。
diff --git a/docs/debt/frontend.md b/docs/debt/frontend.md
index 7728576..2f79ba0 100644
--- a/docs/debt/frontend.md
+++ b/docs/debt/frontend.md
@@ -55,9 +55,9 @@
## 7. web 界面多语言局部接入
- **状态**:推进中,分批接入。
-- **基线**:已接入面 **21** 个文件——Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo 页,以及**首页整面**(`(app)/+page.svelte`、`(app)/+page.ts` 与 `lib/components/home/` 下 HeroSection、PostIndexSection、FeaturedStory、BackToTop)与**文章域整面**(`(app)/blog/+page.svelte`、`(app)/blog/+page.ts`、`(app)/blog/[slug]/+page.svelte`、`(app)/archives/+page.svelte`、`(app)/archives/+page.ts` 与 `lib/components/article/` 下 ArticleActions、ArticleIndexList、ArchiveTimeline、PaginationNav;ArticleListSkeleton 与 article 桶文件无用户可见文案,不在此列)。跨面共享词收敛在 `ui`(`ui:site.name`、`ui:author.*`、`ui:brand.github`、`ui:meta.*`、`ui:empty.*`),页面标题不再引用中文站名常量。其余页面文案仍硬编码中文,en 模式下界面为混合语言。
-- **词表约定**:按面拆分为独立 namespace 并在 `project.inlang/settings.json` 的 `pathPattern` 注册,`ui` 只承载跨面 chrome 与共享词;同一文案出现在两个面时必须上收到 `ui`,不在各面重复登记;插值必须用 i18next 双花括号 `{{param}}`,单花括号会被当作字面量原样输出;计数词条写 `_one`/`_other` 两个变体,参数名必须为 `count` 才参与 `Intl.PluralRules` 选择,变体缺失时取词回退为原始 key 字符串;词表必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败),故 `apps/web/messages/` 已列入 `.prettierignore`。
-- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(当前 21 个文件,逐批递增且只增不减);`pnpm --filter @myblog/web run generate:i18n` 后核对 `messages/{zh,en}` 各 namespace 的键集合与条数一致(当前 ui 78 / blog 38 / home 37 / auth 7 / common 4)。
+- **基线**:已接入面 **29** 个文件——Header、Footer、NotificationBell、FriendlyLinkDialog、`+error`、demo 页,以及**首页整面**(`(app)/+page.svelte`、`(app)/+page.ts` 与 `lib/components/home/` 下 HeroSection、PostIndexSection、FeaturedStory、BackToTop)、**文章域整面**(`(app)/blog/+page.svelte`、`(app)/blog/+page.ts`、`(app)/blog/[slug]/+page.svelte`、`(app)/archives/+page.svelte`、`(app)/archives/+page.ts` 与 `lib/components/article/` 下 ArticleActions、ArticleIndexList、ArchiveTimeline、PaginationNav)与**用户域整面**(`(app)/login/+page.svelte`、`(app)/profile/+page.svelte`、`(app)/profile/+page.server.ts`、`(app)/favorites/+page.svelte`、`(app)/favorites/+page.server.ts`、`lib/components/user/FollowButton.svelte`、`lib/components/comment/CommentSection.svelte`、`lib/service/index.ts`)。无用户可见文案的文件不在统计内:ArticleListSkeleton、ProfileFormSkeleton、各桶文件,以及 `lib/markdown/`、`lib/motion/` 等纯逻辑模块。跨面共享词收敛在 `ui`(`ui:site.name`、`ui:author.*`、`ui:brand.github`、`ui:meta.*`、`ui:empty.*`、`ui:action.*`、`ui:session.expired`),页面标题不再引用中文站名常量;服务端 load 与 `lib/service/index.ts` 的 toast 后备同样经词表取词。
+- **词表约定**:按面拆分为独立 namespace 并在 `project.inlang/settings.json` 的 `pathPattern` 注册,`ui` 只承载跨面 chrome 与共享词;同一文案出现在两个面时必须上收到 `ui`,不在各面重复登记;插值必须用 i18next 双花括号 `{{param}}`,单花括号会被当作字面量原样输出;计数词条写 `_one`/`_other` 两个变体,参数名必须为 `count` 才参与 `Intl.PluralRules` 选择,变体缺失时取词回退为原始 key 字符串;词表必须保持 JSON 兼容写法(paraglide 编译器按严格 JSON 解析,json5 特性直接编译失败),故 `apps/web/messages/` 已列入 `.prettierignore`;句子被节点切开时拆成 `…Before` / 链接文案 / `…After` 多条词条,不把 HTML 写进词条。
+- **验证命令**:`git grep -ln "\$i18n" -- apps/web/src`(当前 29 个文件,逐批递增且只增不减);`pnpm --filter @myblog/web run generate:i18n` 后核对 `messages/{zh,en}` 各 namespace 的键集合与条数一致(当前 ui 80 / account 61 / blog 37 / home 37 / comment 16 / auth 7 / common 4);`pnpm --filter @myblog/web run test`(`vitest.config.ts` 已声明 `$i18n` 别名,单测引用取词模块前需先编译词表)。
- **红线**:已接入文件禁止回退硬编码,不得在已接入文件里新增中文字面量;新增用户可见文案优先经 `m.*` 取词,页面文案进本面 namespace 不塞回 `ui`;其余页面待页面大变动后分批推进。
## 8. 字典页窄屏交互与工具栏布局遗留
diff --git a/docs/development.md b/docs/development.md
index fc5a001..8a5bbd2 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -554,6 +554,8 @@ const updated = await UserAPI.updateUser({ id: user.id, username: 'new-name', em
- **句子被节点切开时按片段取词**:完整句子中间嵌链接或强调节点时,拆成 `…Before` / 链接文案 / `…After` 多条词条,语序由词条内容决定,不把 HTML 写进词条
- `messages/*.json5` 必须保持 **JSON 兼容写法**(双引号、无尾逗号、不写注释):paraglide 编译器按严格 JSON 解析,无引号键/尾逗号/单引号会直接编译失败;`apps/web/messages/` 已列入 `.prettierignore`,因为 prettier 的 json5 解析器会把键改写为无引号形式,直接导致编译失败
- 修改词表后需重新编译生成 `src/lib/paraglide` 产物:`pnpm --filter @myblog/web exec paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide`,等价入口为 `pnpm --filter @myblog/web run generate:i18n`(`vite dev`/`build` 亦会自动触发)
+- `apps/web/vitest.config.ts` 已声明 `$i18n` 别名,单测可引用取词模块,但取词模块是编译产物,跑 `pnpm --filter @myblog/web run test` 前需先执行 `generate:i18n`
+- 后台 `apps/admin` 无 i18n,`packages/*` 无法解析 `$i18n` 别名:共享包不得内置用户可见文案,需要展示的提示一律经回调由应用侧注入(见 `docs/debt/architecture.md` 第 8 条)
## 部署指南
From ae78c13fd679ee3c2bf03e972ab26ca1b8379ee8 Mon Sep 17 00:00:00 2001
From: idleRain
Date: Wed, 14 Oct 2026 17:48:22 +0800
Subject: [PATCH 5/7] =?UTF-8?q?feat(i18n):=20=E8=81=9A=E5=90=88=E9=A1=B5?=
=?UTF-8?q?=E4=B8=8E=E5=B1=95=E4=BD=8D=E7=BB=84=E4=BB=B6=E6=8E=A5=E5=85=A5?=
=?UTF-8?q?=E8=AF=8D=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
新增 category 与 author 两个 namespace,分类页与作者页的标题、标注、统计与空状态改经词表取词。
展位组件 PagePlaceholder 的标题模式、排期说明与返回入口改经词表,web 侧仅剩四个静态页引用中文站名常量。
跨面同文上收至 ui:篇数计数、持续更新、文章列表加载失败、返回首页与“标题 - 站名”模式,先前批次与本次的消费点同步切换。
债务登记同步:frontend 第 7 条基线更新为 34 个已接入文件,并补记取值须用 $derived 的纪律。
---
apps/web/messages/en/account.json5 | 2 --
apps/web/messages/en/author.json5 | 13 +++++++++++
apps/web/messages/en/blog.json5 | 2 --
apps/web/messages/en/category.json5 | 7 ++++++
apps/web/messages/en/ui.json5 | 14 ++++++++----
apps/web/messages/zh/account.json5 | 2 --
apps/web/messages/zh/author.json5 | 13 +++++++++++
apps/web/messages/zh/blog.json5 | 2 --
apps/web/messages/zh/category.json5 | 7 ++++++
apps/web/messages/zh/ui.json5 | 14 ++++++++----
apps/web/project.inlang/settings.json | 4 +++-
.../components/home/PostIndexSection.svelte | 2 +-
.../components/layout/PagePlaceholder.svelte | 13 +++++++----
.../src/routes/(app)/author/[id]/+page.svelte | 22 +++++++++++--------
.../web/src/routes/(app)/author/[id]/+page.ts | 5 +++--
apps/web/src/routes/(app)/blog/+page.svelte | 2 +-
apps/web/src/routes/(app)/blog/+page.ts | 2 +-
.../src/routes/(app)/blog/[slug]/+page.svelte | 2 +-
.../routes/(app)/category/[slug]/+page.svelte | 20 ++++++++++++-----
.../src/routes/(app)/category/[slug]/+page.ts | 5 +++--
.../src/routes/(app)/favorites/+page.svelte | 2 +-
apps/web/src/routes/+error.svelte | 4 ++--
docs/debt/frontend.md | 7 +++---
23 files changed, 116 insertions(+), 50 deletions(-)
create mode 100644 apps/web/messages/en/author.json5
create mode 100644 apps/web/messages/en/category.json5
create mode 100644 apps/web/messages/zh/author.json5
create mode 100644 apps/web/messages/zh/category.json5
diff --git a/apps/web/messages/en/account.json5 b/apps/web/messages/en/account.json5
index 04d0f0d..0bf8a21 100644
--- a/apps/web/messages/en/account.json5
+++ b/apps/web/messages/en/account.json5
@@ -56,8 +56,6 @@
"description": "Posts saved by the signed-in user.",
"eyebrow": "Favorites · Bookmarks",
"heading": "Favorites",
- "count_one": "{{count}} saved post",
- "count_other": "{{count}} saved posts",
"emptyTitle": "No saved posts yet.",
"emptyNote": "Use the save button on a post to collect it here.",
"loadFailed": "Failed to load the saved posts, please try again later"
diff --git a/apps/web/messages/en/author.json5 b/apps/web/messages/en/author.json5
new file mode 100644
index 0000000..fc8b055
--- /dev/null
+++ b/apps/web/messages/en/author.json5
@@ -0,0 +1,13 @@
+{
+ "title": "{{name}} - Author - {{site}}",
+ "description": "All posts published by {{name}}",
+ "eyebrow": "Author · Profile",
+ "articleCount_one": "{{count}} article",
+ "articleCount_other": "{{count}} articles",
+ "followerCount_one": "{{count}} follower",
+ "followerCount_other": "{{count}} followers",
+ "followingCount": "{{count}} following",
+ "emptyTitle": "This author has no published posts yet.",
+ "emptyNote": "Browse the post index for other content.",
+ "notFound": "Author not found"
+}
diff --git a/apps/web/messages/en/blog.json5 b/apps/web/messages/en/blog.json5
index 0bae6bf..c44cab0 100644
--- a/apps/web/messages/en/blog.json5
+++ b/apps/web/messages/en/blog.json5
@@ -15,7 +15,6 @@
"searchEmptyAfter": "to browse every issue."
},
"detail": {
- "title": "{{title}} - {{site}}",
"eyebrow": "Journal · Post",
"commentsClosed": "Comments are closed for this post.",
"backToIndex": "← Back to the index"
@@ -45,7 +44,6 @@
"position": "Page {{current}} / {{total}}"
},
"error": {
- "listFailed": "Failed to load the post list, please try again later",
"archivesFailed": "Failed to load the archive data, please try again later"
}
}
diff --git a/apps/web/messages/en/category.json5 b/apps/web/messages/en/category.json5
new file mode 100644
index 0000000..7f6f518
--- /dev/null
+++ b/apps/web/messages/en/category.json5
@@ -0,0 +1,7 @@
+{
+ "title": "{{name}} - Category - {{site}}",
+ "eyebrow": "Category · {{slug}}",
+ "emptyTitle": "No published posts in this category yet.",
+ "emptyNote": "Browse the post index for other content.",
+ "notFound": "Category not found"
+}
diff --git a/apps/web/messages/en/ui.json5 b/apps/web/messages/en/ui.json5
index fb1750d..b746bb9 100644
--- a/apps/web/messages/en/ui.json5
+++ b/apps/web/messages/en/ui.json5
@@ -17,8 +17,10 @@
"minutesReadApprox": "about {{count}} min",
"views_one": "{{count}} view",
"views_other": "{{count}} views",
- "postCount_one": "{{count}} post · continuously updated",
- "postCount_other": "{{count}} posts · continuously updated"
+ "postCount_one": "{{count}} post",
+ "postCount_other": "{{count}} posts",
+ "ongoing": "continuously updated",
+ "pageTitle": "{{title}} - {{site}}"
},
"empty": {
"inPreparation": "The inaugural issue is in preparation, posts will follow soon.",
@@ -26,11 +28,15 @@
},
"action": {
"failed": "Something went wrong, please try again later",
- "submitting": "Submitting…"
+ "submitting": "Submitting…",
+ "backHome": "Back home"
},
"session": {
"expired": "Your session has expired, please sign in again"
},
+ "placeholder": {
+ "scheduleNote": "Layout in progress · this section will arrive in a later iteration"
+ },
"button": {
"save": "Save",
"cancel": "Cancel",
@@ -109,6 +115,6 @@
"serverErrorTitle": "The printing press broke down",
"serverErrorSubtitle": "The server ran into an unexpected problem and the content is temporarily unavailable",
"retry": "Retry",
- "backHome": "Back home"
+ "listFailed": "Failed to load the post list, please try again later"
}
}
diff --git a/apps/web/messages/zh/account.json5 b/apps/web/messages/zh/account.json5
index 725e481..1bcf101 100644
--- a/apps/web/messages/zh/account.json5
+++ b/apps/web/messages/zh/account.json5
@@ -56,8 +56,6 @@
"description": "当前登录用户收藏的文章列表。",
"eyebrow": "收藏 · Bookmarks",
"heading": "我的收藏",
- "count_one": "共 {{count}} 篇",
- "count_other": "共 {{count}} 篇",
"emptyTitle": "还没有收藏任何文章。",
"emptyNote": "在文章页点击收藏按钮,即可在这里找到它们。",
"loadFailed": "收藏列表加载失败,请稍后重试"
diff --git a/apps/web/messages/zh/author.json5 b/apps/web/messages/zh/author.json5
new file mode 100644
index 0000000..d697002
--- /dev/null
+++ b/apps/web/messages/zh/author.json5
@@ -0,0 +1,13 @@
+{
+ "title": "{{name}} - 作者主页 - {{site}}",
+ "description": "{{name}}发布的全部文章",
+ "eyebrow": "作者 · Author",
+ "articleCount_one": "文章 {{count}} 篇",
+ "articleCount_other": "文章 {{count}} 篇",
+ "followerCount_one": "粉丝 {{count}}",
+ "followerCount_other": "粉丝 {{count}}",
+ "followingCount": "关注 {{count}}",
+ "emptyTitle": "该作者暂无已发布的文章。",
+ "emptyNote": "可以先去目录页看看其他内容。",
+ "notFound": "作者不存在"
+}
diff --git a/apps/web/messages/zh/blog.json5 b/apps/web/messages/zh/blog.json5
index 516367a..6661a32 100644
--- a/apps/web/messages/zh/blog.json5
+++ b/apps/web/messages/zh/blog.json5
@@ -15,7 +15,6 @@
"searchEmptyAfter": "浏览全部刊目。"
},
"detail": {
- "title": "{{title}} - {{site}}",
"eyebrow": "手记 · 文章",
"commentsClosed": "这篇文章已关闭评论。",
"backToIndex": "← 返回目录"
@@ -45,7 +44,6 @@
"position": "第 {{current}} / {{total}} 页"
},
"error": {
- "listFailed": "文章列表加载失败,请稍后重试",
"archivesFailed": "归档数据加载失败,请稍后重试"
}
}
diff --git a/apps/web/messages/zh/category.json5 b/apps/web/messages/zh/category.json5
new file mode 100644
index 0000000..7cdef32
--- /dev/null
+++ b/apps/web/messages/zh/category.json5
@@ -0,0 +1,7 @@
+{
+ "title": "{{name}} - 分类目录 - {{site}}",
+ "eyebrow": "分类 · {{slug}}",
+ "emptyTitle": "该分类下暂无已发布的文章。",
+ "emptyNote": "可以去目录页看看其他内容。",
+ "notFound": "分类不存在"
+}
diff --git a/apps/web/messages/zh/ui.json5 b/apps/web/messages/zh/ui.json5
index 4e2457b..c380b13 100644
--- a/apps/web/messages/zh/ui.json5
+++ b/apps/web/messages/zh/ui.json5
@@ -17,8 +17,10 @@
"minutesReadApprox": "约 {{count}} 分钟",
"views_one": "{{count}} 次浏览",
"views_other": "{{count}} 次浏览",
- "postCount_one": "共 {{count}} 篇 · 持续更新",
- "postCount_other": "共 {{count}} 篇 · 持续更新"
+ "postCount_one": "共 {{count}} 篇",
+ "postCount_other": "共 {{count}} 篇",
+ "ongoing": "持续更新",
+ "pageTitle": "{{title}} - {{site}}"
},
"empty": {
"inPreparation": "创刊号正在筹备中,文章即将发布。",
@@ -26,11 +28,15 @@
},
"action": {
"failed": "操作失败,请稍后重试",
- "submitting": "提交中…"
+ "submitting": "提交中…",
+ "backHome": "返回首页"
},
"session": {
"expired": "登录已过期,请重新登录"
},
+ "placeholder": {
+ "scheduleNote": "版面排期中 · 功能将在后续迭代接入"
+ },
"button": {
"save": "保存",
"cancel": "取消",
@@ -109,6 +115,6 @@
"serverErrorTitle": "印刷机出了点故障",
"serverErrorSubtitle": "服务器遇到了意外状况,内容暂时无法呈现",
"retry": "重试加载",
- "backHome": "返回首页"
+ "listFailed": "文章列表加载失败,请稍后重试"
}
}
diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json
index 7cd5612..e5c440c 100644
--- a/apps/web/project.inlang/settings.json
+++ b/apps/web/project.inlang/settings.json
@@ -12,7 +12,9 @@
"home": "./messages/{locale}/home.json5",
"blog": "./messages/{locale}/blog.json5",
"account": "./messages/{locale}/account.json5",
- "comment": "./messages/{locale}/comment.json5"
+ "comment": "./messages/{locale}/comment.json5",
+ "category": "./messages/{locale}/category.json5",
+ "author": "./messages/{locale}/author.json5"
}
},
"baseLocale": "zh",
diff --git a/apps/web/src/lib/components/home/PostIndexSection.svelte b/apps/web/src/lib/components/home/PostIndexSection.svelte
index 237bdd6..5e2b496 100644
--- a/apps/web/src/lib/components/home/PostIndexSection.svelte
+++ b/apps/web/src/lib/components/home/PostIndexSection.svelte
@@ -34,7 +34,7 @@ function handleSubscribe(event: SubmitEvent) {
diff --git a/apps/web/src/lib/components/layout/PagePlaceholder.svelte b/apps/web/src/lib/components/layout/PagePlaceholder.svelte
index 69dd8f3..df1c938 100644
--- a/apps/web/src/lib/components/layout/PagePlaceholder.svelte
+++ b/apps/web/src/lib/components/layout/PagePlaceholder.svelte
@@ -1,5 +1,5 @@
- {title} - {SITE_NAME_ZH}
+ {pageTitle}
@@ -33,7 +36,9 @@ let { eyebrow, ghostMark, title, description }: Props = $props()
-
@@ -45,7 +50,7 @@ let { eyebrow, ghostMark, title, description }: Props = $props()
href="/"
class="group mt-12 inline-flex items-center gap-2 text-sm font-bold text-signal underline-offset-4 hover:underline"
>
- 返回首页
+ {m['ui:action.backHome']()}
import { ArticleIndexList, PaginationNav } from '$lib/components/article'
import { FollowButton } from '$lib/components/user'
-import { SITE_NAME_ZH } from '@myblog/shared'
import type { PageProps } from './$types'
+import { m } from '$i18n'
let { data }: PageProps = $props()
@@ -11,13 +11,17 @@ const profile = $derived(data.profile)
// 展示名优先取昵称,缺失时回退用户名。
const displayName = $derived(profile.nickname || profile.username)
+// 标题与描述随语言切换,站名取自词表。
+const pageTitle = $derived(m['author:title']({ name: displayName, site: m['ui:site.name']() }))
+const pageDescription = $derived(profile.bio || m['author:description']({ name: displayName }))
+
// 总页数向上取整,无文章时保持 1 以呈现完整导航骨架。
const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pageSize)))
- {displayName} - 作者主页 - {SITE_NAME_ZH}
-
+ {pageTitle}
+
@@ -35,7 +39,7 @@ const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pa
- 文章 {profile.articleCount} 篇
- 粉丝 {profile.followerCount}
- 关注 {profile.followingCount}
+ {m['author:articleCount']({ count: profile.articleCount })}
+ {m['author:followerCount']({ count: profile.followerCount })}
+ {m['author:followingCount']({ count: profile.followingCount })}
{#if profile.website}
{#if data.list.articles.length === 0}
-
{:else}
{
const profileResponse = await UserAPI.getPublicProfile(authorId)
if (profileResponse.code !== SUCCESS_CODE || !profileResponse.data) {
- throw error(404, '作者不存在')
+ throw error(404, m['author:notFound']())
}
const profile: PublicProfile = profileResponse.data
@@ -27,7 +28,7 @@ export const load: PageLoad = async ({ params, url }) => {
order: 'desc'
})
if (listResponse.code !== SUCCESS_CODE || !listResponse.data) {
- throw error(503, '文章列表加载失败,请稍后重试')
+ throw error(503, m['ui:error.listFailed']())
}
return { profile, list: listResponse.data, currentPage }
diff --git a/apps/web/src/routes/(app)/blog/+page.svelte b/apps/web/src/routes/(app)/blog/+page.svelte
index a8dacd1..dc53a24 100644
--- a/apps/web/src/routes/(app)/blog/+page.svelte
+++ b/apps/web/src/routes/(app)/blog/+page.svelte
@@ -40,7 +40,7 @@ const searchQuery = $derived(data.search ? `search=${encodeURIComponent(data.sea
{:else}
- {m['ui:meta.postCount']({ count: data.list.total })}
+ {m['ui:meta.postCount']({ count: data.list.total })} · {m['ui:meta.ongoing']()}
{/if}
diff --git a/apps/web/src/routes/(app)/blog/+page.ts b/apps/web/src/routes/(app)/blog/+page.ts
index 98bd027..ff560f6 100644
--- a/apps/web/src/routes/(app)/blog/+page.ts
+++ b/apps/web/src/routes/(app)/blog/+page.ts
@@ -25,7 +25,7 @@ export const load: PageLoad = async ({ url }) => {
})
if (response.code !== RESPONSE_CODE_SUCCESS || !response.data) {
- throw error(503, m['blog:error.listFailed']())
+ throw error(503, m['ui:error.listFailed']())
}
return { list: response.data, currentPage, search }
diff --git a/apps/web/src/routes/(app)/blog/[slug]/+page.svelte b/apps/web/src/routes/(app)/blog/[slug]/+page.svelte
index 3bae6b5..f0c8fa9 100644
--- a/apps/web/src/routes/(app)/blog/[slug]/+page.svelte
+++ b/apps/web/src/routes/(app)/blog/[slug]/+page.svelte
@@ -25,7 +25,7 @@ $effect(() => {
{m['blog:detail.title']({
+ >{m['ui:meta.pageTitle']({
title: article.seoTitle || article.title,
site: m['ui:site.name']()
})}
import { ArticleIndexList, PaginationNav } from '$lib/components/article'
-import { SITE_NAME_ZH } from '@myblog/shared'
import type { PageProps } from './$types'
+import { m } from '$i18n'
let { data }: PageProps = $props()
const category = $derived(data.category)
+// 标题与栏目标注随语言切换,站名取自词表。
+const pageTitle = $derived(
+ m['category:title']({
+ name: category.seoTitle || category.name,
+ site: m['ui:site.name']()
+ })
+)
+
// 总页数向上取整,无文章时保持 1 以呈现完整导航骨架。
const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pageSize)))
- {category.seoTitle || category.name} - 分类目录 - {SITE_NAME_ZH}
+ {pageTitle}
@@ -23,13 +31,13 @@ const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pa
{#if category.description}
@@ -42,8 +50,8 @@ const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pa
{#if data.list.articles.length === 0}
-
{:else}
{
const categoryResponse = await CategoryAPI.getBySlug(params.slug)
if (categoryResponse.code !== RESPONSE_CODE_SUCCESS || !categoryResponse.data) {
- throw error(404, '分类不存在')
+ throw error(404, m['category:notFound']())
}
const listResponse = await ArticleAPI.byCategory(categoryResponse.data.id, {
@@ -23,7 +24,7 @@ export const load: PageLoad = async ({ params, url }) => {
order: 'desc'
})
if (listResponse.code !== RESPONSE_CODE_SUCCESS || !listResponse.data) {
- throw error(503, '文章列表加载失败,请稍后重试')
+ throw error(503, m['ui:error.listFailed']())
}
return { category: categoryResponse.data, list: listResponse.data, currentPage }
diff --git a/apps/web/src/routes/(app)/favorites/+page.svelte b/apps/web/src/routes/(app)/favorites/+page.svelte
index 55c3bdd..4b4ea92 100644
--- a/apps/web/src/routes/(app)/favorites/+page.svelte
+++ b/apps/web/src/routes/(app)/favorites/+page.svelte
@@ -50,7 +50,7 @@ const skeletonRows = $derived(Math.max(MIN_SKELETON_ROWS, articles.length))
- {m['account:favorites.count']({ count: total })}
+ {m['ui:meta.postCount']({ count: total })}
diff --git a/apps/web/src/routes/+error.svelte b/apps/web/src/routes/+error.svelte
index dcb3e53..260061c 100644
--- a/apps/web/src/routes/+error.svelte
+++ b/apps/web/src/routes/+error.svelte
@@ -68,14 +68,14 @@ const errorSubtitle = $derived(
href="/"
class="inline-flex items-center gap-2 border border-border px-7 py-3.5 text-sm font-bold text-foreground transition-[border-color,color,transform] duration-200 ease-(--ease-out-strong) hover:border-signal hover:text-signal active:scale-[0.97]"
>
- {m['ui:error.backHome']()}
+ {m['ui:action.backHome']()}
{:else}
- {m['ui:error.backHome']()}
+ {m['ui:action.backHome']()}
Date: Wed, 14 Oct 2026 17:52:46 +0800
Subject: [PATCH 6/7] =?UTF-8?q?feat(i18n):=20=E8=81=94=E7=B3=BB=E4=B8=8E?=
=?UTF-8?q?=E6=A1=A3=E6=A1=88=E4=B8=A4=E4=B8=AA=E9=9D=99=E6=80=81=E9=A1=B5?=
=?UTF-8?q?=E6=8E=A5=E5=85=A5=E8=AF=8D=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
新增 contact 与 projects 两个 namespace,含两个页面的结构性文案与全部正文散文的英译。
联系渠道的图标分支改按 icon 标识判断,不再依赖已翻译的渠道名,避免改名后错配图标。
跨面同文上收至 ui:邮箱标签(contact 渠道名与评论表单标签共用)。
静态页右下角幽灵字以命名常量声明并注明为装饰字形,不进词表。
债务登记同步:frontend 第 7 条基线更新为 36 个已接入文件,并补记装饰字形例外与分支判定纪律。
---
apps/web/messages/en/comment.json5 | 1 -
apps/web/messages/en/contact.json5 | 13 +++++
apps/web/messages/en/projects.json5 | 16 ++++++
apps/web/messages/en/ui.json5 | 3 ++
apps/web/messages/zh/comment.json5 | 1 -
apps/web/messages/zh/contact.json5 | 13 +++++
apps/web/messages/zh/projects.json5 | 16 ++++++
apps/web/messages/zh/ui.json5 | 3 ++
apps/web/project.inlang/settings.json | 4 +-
.../components/comment/CommentSection.svelte | 2 +-
.../web/src/routes/(app)/contact/+page.svelte | 51 ++++++++++++-------
.../src/routes/(app)/projects/+page.svelte | 46 ++++++++++-------
docs/debt/frontend.md | 9 ++--
13 files changed, 133 insertions(+), 45 deletions(-)
create mode 100644 apps/web/messages/en/contact.json5
create mode 100644 apps/web/messages/en/projects.json5
create mode 100644 apps/web/messages/zh/contact.json5
create mode 100644 apps/web/messages/zh/projects.json5
diff --git a/apps/web/messages/en/comment.json5 b/apps/web/messages/en/comment.json5
index 8dd076c..a3af41b 100644
--- a/apps/web/messages/en/comment.json5
+++ b/apps/web/messages/en/comment.json5
@@ -4,7 +4,6 @@
"count_other": "{{count}} comments",
"nameLabel": "Name",
"namePlaceholder": "Name *",
- "emailLabel": "Email",
"emailPlaceholder": "Email (not published)",
"contentLabel": "Comment",
"contentPlaceholder": "Say something",
diff --git a/apps/web/messages/en/contact.json5 b/apps/web/messages/en/contact.json5
new file mode 100644
index 0000000..b119e13
--- /dev/null
+++ b/apps/web/messages/en/contact.json5
@@ -0,0 +1,13 @@
+{
+ "heading": "Contact",
+ "description": "The real channels for reaching the {{site}} author: GitHub, email and link exchange.",
+ "eyebrow": "Correspondence · Contact",
+ "lead": "Letters are welcome, whether it is a correction, a technical discussion or simply saying hello.",
+ "channels": {
+ "emailNote": "Write in for collaboration or long-form exchanges; replies usually arrive within two to three working days.",
+ "githubNote": "Issues and discussions suit technical topics best, and progress stays visible."
+ },
+ "inSiteTitle": "On-site channels",
+ "inSiteComments": "Comments: leave a note under any post; guests may comment and the author reads every one.",
+ "inSiteLinks": "Link exchange: submit an application at the bottom of the friendly-links dialog in the header; approved links appear there."
+}
diff --git a/apps/web/messages/en/projects.json5 b/apps/web/messages/en/projects.json5
new file mode 100644
index 0000000..f931012
--- /dev/null
+++ b/apps/web/messages/en/projects.json5
@@ -0,0 +1,16 @@
+{
+ "heading": "Projects",
+ "description": "An archive of personal and open-source work, currently featuring the {{site}} full-stack project.",
+ "eyebrow": "Archive · Projects",
+ "lead": "Everything here is real and verifiable; each entry is updated as the project evolves.",
+ "card": {
+ "title": "MyBlog · {{site}}",
+ "meta": "Since 2026 · under continuous iteration",
+ "paragraphOne": "The site you are reading is the first entry in this archive: a full-stack personal blog built with Go and SvelteKit, covering eleven business modules including articles, comments, favorites, follows, notifications, statistics and friendly links, with role-based access control and Chinese full-text search.",
+ "paragraphTwo": "The project is organised as a pnpm monorepo: the frontend is split into five shared packages, namely api, http, auth, shared and ui, while the backend is layered into handler, service and repository. The comment moderation state machine, the notification pipeline and the backup and restore scripts are real implementations rather than demo samples.",
+ "sourceLink": "View the source repository"
+ },
+ "techStackTitle": "Tech stack",
+ "moreTitle": "More entries are being prepared and will appear as they are ready.",
+ "moreNote": "New work shows up first in the post index as a journal entry, then moves here."
+}
diff --git a/apps/web/messages/en/ui.json5 b/apps/web/messages/en/ui.json5
index b746bb9..fa6900f 100644
--- a/apps/web/messages/en/ui.json5
+++ b/apps/web/messages/en/ui.json5
@@ -5,6 +5,9 @@
"brand": {
"github": "GitHub"
},
+ "label": {
+ "email": "Email"
+ },
"author": {
"name": "Developer",
"role": "Full-stack engineer",
diff --git a/apps/web/messages/zh/comment.json5 b/apps/web/messages/zh/comment.json5
index c9f1932..51f7fe0 100644
--- a/apps/web/messages/zh/comment.json5
+++ b/apps/web/messages/zh/comment.json5
@@ -4,7 +4,6 @@
"count_other": "共 {{count}} 条",
"nameLabel": "姓名",
"namePlaceholder": "姓名 *",
- "emailLabel": "邮箱",
"emailPlaceholder": "邮箱(不公开)",
"contentLabel": "评论内容",
"contentPlaceholder": "说点什么吧",
diff --git a/apps/web/messages/zh/contact.json5 b/apps/web/messages/zh/contact.json5
new file mode 100644
index 0000000..6aebdef
--- /dev/null
+++ b/apps/web/messages/zh/contact.json5
@@ -0,0 +1,13 @@
+{
+ "heading": "联系方式",
+ "description": "与{{site}}站长取得联系的真实渠道:GitHub、邮箱与友链互换。",
+ "eyebrow": "往来 · Contact",
+ "lead": "欢迎写信交流,无论是勘误指正、技术讨论还是单纯打个招呼。",
+ "channels": {
+ "emailNote": "合作与长文交流请来信,工作日通常两至三天内回复。",
+ "githubNote": "Issue 与讨论最适合技术话题,处理进度可见。"
+ },
+ "inSiteTitle": "站内通道",
+ "inSiteComments": "评论留言:任意文章页下方均可留言,游客可评,站长会逐条查看。",
+ "inSiteLinks": "友链互换:在页头「友情链接」弹窗底部提交申请,通过审核后即会展示。"
+}
diff --git a/apps/web/messages/zh/projects.json5 b/apps/web/messages/zh/projects.json5
new file mode 100644
index 0000000..aca9b8f
--- /dev/null
+++ b/apps/web/messages/zh/projects.json5
@@ -0,0 +1,16 @@
+{
+ "heading": "项目档案",
+ "description": "个人项目与开源作品的档案陈列,当前收录{{site}}全栈工程。",
+ "eyebrow": "档案 · Projects",
+ "lead": "这里陈列真实可查证的作品,每份档案随项目演进同步更新。",
+ "card": {
+ "title": "MyBlog · {{site}}",
+ "meta": "2026 年起 · 持续迭代",
+ "paragraphOne": "你正在浏览的站点,本身就是档案里的第一件作品:一套 Go 与 SvelteKit 构成的全栈个人博客工程,覆盖文章、评论、收藏、关注、通知、统计与友链等十一个业务模块,支持角色权限控制与中文全文检索。",
+ "paragraphTwo": "工程采用 pnpm Monorepo 组织:前端拆分为 api、http、auth、shared、ui 五个共享包,后端按 handler、service、repository 三层分层;评论审核状态机、通知生产链路与备份恢复脚本均为真实实现,而非演示样例。",
+ "sourceLink": "查看源码仓库"
+ },
+ "techStackTitle": "技术构成",
+ "moreTitle": "更多档案整理中,随刊出陆续上架。",
+ "moreNote": "新的作品会先在博客目录以手记形式亮相,再归入此处。"
+}
diff --git a/apps/web/messages/zh/ui.json5 b/apps/web/messages/zh/ui.json5
index c380b13..bbafa80 100644
--- a/apps/web/messages/zh/ui.json5
+++ b/apps/web/messages/zh/ui.json5
@@ -5,6 +5,9 @@
"brand": {
"github": "GitHub"
},
+ "label": {
+ "email": "邮箱"
+ },
"author": {
"name": "开发者",
"role": "全栈开发工程师",
diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json
index e5c440c..722ff3a 100644
--- a/apps/web/project.inlang/settings.json
+++ b/apps/web/project.inlang/settings.json
@@ -14,7 +14,9 @@
"account": "./messages/{locale}/account.json5",
"comment": "./messages/{locale}/comment.json5",
"category": "./messages/{locale}/category.json5",
- "author": "./messages/{locale}/author.json5"
+ "author": "./messages/{locale}/author.json5",
+ "contact": "./messages/{locale}/contact.json5",
+ "projects": "./messages/{locale}/projects.json5"
}
},
"baseLocale": "zh",
diff --git a/apps/web/src/lib/components/comment/CommentSection.svelte b/apps/web/src/lib/components/comment/CommentSection.svelte
index dbaa3f2..5183cc6 100644
--- a/apps/web/src/lib/components/comment/CommentSection.svelte
+++ b/apps/web/src/lib/components/comment/CommentSection.svelte
@@ -179,7 +179,7 @@ async function handleSubmit(event: SubmitEvent) {
/>
- 收藏 · Bookmarks + {m['account:favorites.eyebrow']()}
-我的收藏
+{m['account:favorites.heading']()}
- 共 {total} 篇 + + {m['account:favorites.count']({ count: total })} + {#if isNavigatingHere} @@ -57,8 +62,8 @@ const skeletonRows = $derived(Math.max(MIN_SKELETON_ROWS, articles.length))还没有收藏任何文章。
-在文章页点击收藏按钮,即可在这里找到它们。
+{m['account:favorites.emptyTitle']()}
+{m['account:favorites.emptyNote']()}
- 门户 · Auth + {m['account:login.eyebrow']()}
-欢迎回来
++ {m['account:login.heading']()} +
- 登录后即可参与评论、点赞、收藏与关注等互动。 + {m['account:login.description']()}
- 尚无账户时可通过评论区以访客身份留言,或联系站长开通。 + {m['account:login.guestNote']()}
diff --git a/apps/web/src/routes/(app)/profile/+page.server.ts b/apps/web/src/routes/(app)/profile/+page.server.ts index 5f668c3..64c735d 100644 --- a/apps/web/src/routes/(app)/profile/+page.server.ts +++ b/apps/web/src/routes/(app)/profile/+page.server.ts @@ -2,13 +2,11 @@ import { fetchAuthenticated } from '$lib/service/ssr' import { error, redirect } from '@sveltejs/kit' import type { PageServerLoad } from './$types' import { createUserAPI } from '@myblog/api' +import { m } from '$i18n' // 未登录或会话缺失时统一跳转登录页,由登录页承接身份建立。 const LOGIN_PATH = '/login' -// 资料读取失败时的页面级提示,与既有客户端补拉的文案保持一致。 -const LOAD_FAILURE_MESSAGE = '资料加载失败,请稍后重试' - /** * 个人资料页在服务端取数。 * 会话 Cookie 由 fetchAuthenticated 注入请求,后端据此识别登录身份, @@ -24,7 +22,7 @@ export const load: PageServerLoad = async ({ request }) => { throw redirect(302, LOGIN_PATH) } if (result.status === 'failed') { - throw error(503, LOAD_FAILURE_MESSAGE) + throw error(503, m['account:profile.loadFailed']()) } return { profile: result.data } diff --git a/apps/web/src/routes/(app)/profile/+page.svelte b/apps/web/src/routes/(app)/profile/+page.svelte index 18fffd5..b235f41 100644 --- a/apps/web/src/routes/(app)/profile/+page.svelte +++ b/apps/web/src/routes/(app)/profile/+page.svelte @@ -2,13 +2,13 @@ import type { ProfileUser } from '@myblog/api/modules/user/types' import { ProfileFormSkeleton } from '$lib/components/user' import { RESPONSE_CODE_SUCCESS } from '@myblog/shared' -import { SITE_NAME_ZH } from '@myblog/shared' import { authStore } from '$lib/stores/auth' import type { PageProps } from './$types' import { navigating } from '$app/state' import { goto } from '$app/navigation' import { toast } from 'svelte-sonner' import { UserAPI } from '$lib/api' +import { m } from '$i18n' // 资料字段长度上限,与后端 UpdateProfileRequest 的 binding 规则一致。 const NICKNAME_MAX_LENGTH = 50 @@ -23,6 +23,9 @@ const PASSWORD_MAX_LENGTH = 64 // 数据由 +page.server.ts 的 load 在服务端取回,未登录时 load 已跳转登录页。 let { data }: PageProps = $props() +// 标题中的站名取自词表,以随语言切换。 +const pageTitle = m['account:profile.title']({ site: m['ui:site.name']() }) + // 资料展示口径取自 load 结果;保存成功后以响应体覆盖,使界面与后端一致。 // 经函数读取而非直接引用 data,避免状态声明处只捕获 load 的初值而产生告警。 let loadedProfile = $state- 资料 · Profile + {m['account:profile.eyebrow']()}
-个人资料
+{m['account:profile.heading']()}
{#if isNavigatingHere} @@ -161,50 +161,50 @@ async function handlePasswordSubmit(event: SubmitEvent) {{m['home:index.title']()}
- {m['ui:meta.postCount']({ count: posts.length })} + {m['ui:meta.postCount']({ count: posts.length })} · {m['ui:meta.ongoing']()}版面排期中 · 功能将在后续迭代接入
++ {m['ui:placeholder.scheduleNote']()} +
- 作者 · Author + {m['author:eyebrow']()}
{displayName}
@@ -52,9 +56,9 @@ const totalPages = $derived(Math.max(1, Math.ceil(data.list.total / data.list.pa该作者暂无已发布的文章。
-可以先去目录页看看其他内容。
+{m['author:emptyTitle']()}
+{m['author:emptyNote']()}
- 分类 · {category.slug} + {m['category:eyebrow']({ slug: category.slug })}
{category.name}
- 共 {data.list.total} 篇 + {m['ui:meta.postCount']({ count: data.list.total })}该分类下暂无已发布的文章。
-可以去目录页看看其他内容。
+{m['category:emptyTitle']()}
+{m['category:emptyNote']()}
{m['account:favorites.heading']()}