gitannals 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chronicle/__init__.py +6 -0
- chronicle/analyze.py +325 -0
- chronicle/clean.py +331 -0
- chronicle/cli.py +306 -0
- chronicle/config.py +132 -0
- chronicle/features/__init__.py +23 -0
- chronicle/features/_util.py +90 -0
- chronicle/features/churn.py +150 -0
- chronicle/features/contributors.py +100 -0
- chronicle/features/fun_facts.py +213 -0
- chronicle/features/languages.py +135 -0
- chronicle/features/milestones.py +435 -0
- chronicle/features/overview.py +81 -0
- chronicle/features/profile.py +382 -0
- chronicle/features/temporal.py +132 -0
- chronicle/gitio/__init__.py +5 -0
- chronicle/gitio/parse.py +135 -0
- chronicle/gitio/runner.py +120 -0
- chronicle/i18n.py +530 -0
- chronicle/identity.py +58 -0
- chronicle/models.py +80 -0
- chronicle/narrate/__init__.py +7 -0
- chronicle/narrate/client.py +124 -0
- chronicle/narrate/enhance.py +137 -0
- chronicle/narrate/prompt.py +232 -0
- chronicle/narrate/schema.py +133 -0
- chronicle/redact.py +301 -0
- chronicle/render/__init__.py +140 -0
- chronicle/render/charts.py +518 -0
- chronicle/render/templates/_style.css.j2 +80 -0
- chronicle/render/templates/author.html.j2 +318 -0
- chronicle/render/templates/report.html.j2 +407 -0
- gitannals-0.1.0.dist-info/METADATA +251 -0
- gitannals-0.1.0.dist-info/RECORD +37 -0
- gitannals-0.1.0.dist-info/WHEEL +4 -0
- gitannals-0.1.0.dist-info/entry_points.txt +2 -0
- gitannals-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Git 子进程封装。
|
|
2
|
+
|
|
3
|
+
三条纪律:
|
|
4
|
+
1. 一律关掉 pager,否则在某些终端下会挂起;
|
|
5
|
+
2. 一律关掉 core.quotepath,否则中文路径会被转义成八进制;
|
|
6
|
+
3. 一律按 UTF-8 解码并容错,Windows 下默认代码页不可信。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
from collections.abc import Iterator
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
__all__ = ["GitError", "resolve_repo", "run", "stream", "repo_meta"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GitError(RuntimeError):
|
|
21
|
+
"""Git 不可用、路径不是仓库、或命令返回非零。"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _git_binary() -> str:
|
|
25
|
+
binary = shutil.which("git")
|
|
26
|
+
if not binary:
|
|
27
|
+
raise GitError("未找到 git,请确认已安装 Git 并加入 PATH")
|
|
28
|
+
return binary
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _base(repo: Path) -> list[str]:
|
|
32
|
+
# 全局选项必须排在子命令之前
|
|
33
|
+
return [
|
|
34
|
+
_git_binary(),
|
|
35
|
+
"-C",
|
|
36
|
+
str(repo),
|
|
37
|
+
"--no-pager",
|
|
38
|
+
"-c",
|
|
39
|
+
"core.quotepath=false",
|
|
40
|
+
"-c",
|
|
41
|
+
"log.showSignature=false",
|
|
42
|
+
"-c",
|
|
43
|
+
"i18n.logOutputEncoding=UTF-8",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def resolve_repo(path: str | os.PathLike[str]) -> Path:
|
|
48
|
+
"""把任意子目录解析成仓库根目录。"""
|
|
49
|
+
candidate = Path(path).expanduser()
|
|
50
|
+
if not candidate.exists():
|
|
51
|
+
raise GitError(f"路径不存在:{candidate}")
|
|
52
|
+
out, code = run(candidate, ["rev-parse", "--show-toplevel"], check=False)
|
|
53
|
+
if code != 0 or not out.strip():
|
|
54
|
+
raise GitError(f"不是 Git 仓库:{candidate}")
|
|
55
|
+
return Path(out.strip())
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def run(
|
|
59
|
+
repo: Path,
|
|
60
|
+
args: list[str],
|
|
61
|
+
*,
|
|
62
|
+
check: bool = True,
|
|
63
|
+
timeout: int = 600,
|
|
64
|
+
) -> tuple[str, int]:
|
|
65
|
+
"""执行一条 git 命令,返回 (stdout, returncode)。"""
|
|
66
|
+
proc = subprocess.run(
|
|
67
|
+
_base(repo) + args,
|
|
68
|
+
capture_output=True,
|
|
69
|
+
timeout=timeout,
|
|
70
|
+
)
|
|
71
|
+
out = proc.stdout.decode("utf-8", errors="replace")
|
|
72
|
+
if check and proc.returncode != 0:
|
|
73
|
+
err = proc.stderr.decode("utf-8", errors="replace").strip()
|
|
74
|
+
raise GitError(f"git {' '.join(args)} 失败:{err}")
|
|
75
|
+
return out, proc.returncode
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def stream(repo: Path, args: list[str]) -> Iterator[str]:
|
|
79
|
+
"""流式读取 git 输出,逐行 yield(已去掉行尾换行)。
|
|
80
|
+
|
|
81
|
+
用 Popen 而不是 subprocess.run,是为了让几十万条提交也能边读边解析,
|
|
82
|
+
不必先把整个输出塞进内存。
|
|
83
|
+
"""
|
|
84
|
+
proc = subprocess.Popen(
|
|
85
|
+
_base(repo) + args,
|
|
86
|
+
stdout=subprocess.PIPE,
|
|
87
|
+
stderr=subprocess.PIPE,
|
|
88
|
+
bufsize=1 << 20,
|
|
89
|
+
)
|
|
90
|
+
assert proc.stdout is not None and proc.stderr is not None
|
|
91
|
+
try:
|
|
92
|
+
for raw in proc.stdout:
|
|
93
|
+
yield raw.decode("utf-8", errors="replace").rstrip("\r\n")
|
|
94
|
+
finally:
|
|
95
|
+
proc.stdout.close()
|
|
96
|
+
err = proc.stderr.read().decode("utf-8", errors="replace").strip()
|
|
97
|
+
proc.stderr.close()
|
|
98
|
+
if proc.wait() != 0:
|
|
99
|
+
raise GitError(f"git {' '.join(args)} 失败:{err}")
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def repo_meta(repo: Path) -> dict[str, str | None]:
|
|
103
|
+
"""仓库名、当前分支、origin 地址。缺哪项给 None,不抛错。"""
|
|
104
|
+
|
|
105
|
+
def _try(args: list[str]) -> str | None:
|
|
106
|
+
out, code = run(repo, args, check=False)
|
|
107
|
+
value = out.strip()
|
|
108
|
+
return value or None if code == 0 else None
|
|
109
|
+
|
|
110
|
+
branch = _try(["rev-parse", "--abbrev-ref", "HEAD"])
|
|
111
|
+
if branch == "HEAD":
|
|
112
|
+
# detached HEAD,退化成短 sha
|
|
113
|
+
branch = _try(["rev-parse", "--short", "HEAD"])
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
"name": repo.name,
|
|
117
|
+
"root": str(repo),
|
|
118
|
+
"branch": branch,
|
|
119
|
+
"remote": _try(["remote", "get-url", "origin"]),
|
|
120
|
+
}
|
chronicle/i18n.py
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
"""文案层。
|
|
2
|
+
|
|
3
|
+
规则叙事和 LLM 叙事的 fallback 共用这套词条 —— 这样 `--no-ai` 和「LLM 挂了」
|
|
4
|
+
走的是同一条代码路径,不会出现两种体验。
|
|
5
|
+
|
|
6
|
+
新增语言只需在 TEXT 里补一份,缺失的 key 回落 zh。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
__all__ = ["t", "LANGS", "chapter_archetypes", "weekdays"]
|
|
14
|
+
|
|
15
|
+
LANGS = ("zh", "en")
|
|
16
|
+
|
|
17
|
+
TEXT: dict[str, dict[str, str]] = {
|
|
18
|
+
"zh": {
|
|
19
|
+
# ---- 概览 ----
|
|
20
|
+
"label.commits": "提交",
|
|
21
|
+
"label.commits_code": "代码提交",
|
|
22
|
+
"label.merges": "合并",
|
|
23
|
+
"label.insertions": "新增行",
|
|
24
|
+
"label.deletions": "删除行",
|
|
25
|
+
"label.net": "净增行",
|
|
26
|
+
"label.files": "涉及文件",
|
|
27
|
+
"label.authors": "贡献者",
|
|
28
|
+
"label.active_days": "活跃天数",
|
|
29
|
+
"label.span_days": "时间跨度",
|
|
30
|
+
"label.since": "起点",
|
|
31
|
+
"label.until": "终点",
|
|
32
|
+
"unit.day": "天",
|
|
33
|
+
"unit.commit": "次",
|
|
34
|
+
"unit.line": "行",
|
|
35
|
+
"unit.person": "人",
|
|
36
|
+
"unit.file": "个",
|
|
37
|
+
# ---- 图表标题 ----
|
|
38
|
+
"title.timeline": "代码量波动",
|
|
39
|
+
"title.rhythm": "开发作息热力图",
|
|
40
|
+
"title.churn": "文件修罗场",
|
|
41
|
+
"title.languages": "语言构成",
|
|
42
|
+
"title.contributors": "贡献者",
|
|
43
|
+
"title.chapters": "演进编年史",
|
|
44
|
+
"title.milestones": "关键节点",
|
|
45
|
+
"title.fun_facts": "考古彩蛋",
|
|
46
|
+
# ---- 热力图 ----
|
|
47
|
+
"rhythm.night": "深夜提交占比",
|
|
48
|
+
"rhythm.weekend": "周末提交占比",
|
|
49
|
+
"rhythm.peak": "最活跃时段",
|
|
50
|
+
"rhythm.peak_value": "周{weekday} {hour} 点",
|
|
51
|
+
# ---- churn 标签 ----
|
|
52
|
+
"churn.tag.hot": "高频改动",
|
|
53
|
+
"churn.tag.brittle": "易碎",
|
|
54
|
+
"churn.tag.silo": "知识孤岛",
|
|
55
|
+
"churn.tag.volatile": "大幅波动",
|
|
56
|
+
"churn.empty": "没有文件达到上榜门槛",
|
|
57
|
+
# ---- 章节叙事 ----
|
|
58
|
+
"chapter.summary": "共 {commits} 次提交,新增 {insertions} 行、删除 {deletions} 行,涉及 {authors} 位贡献者。",
|
|
59
|
+
"chapter.summary_dirs": "主战场在 {dirs}。",
|
|
60
|
+
"chapter.narrative.flat": "总共 {commits} 次提交,横跨 {days} 天。历史还太短,分不出阶段 —— 但一切都从这里开始。",
|
|
61
|
+
"chapter.narrative.genesis": "一切都从 {start} 那天开始。{commits} 次提交,把想法变成了能跑的东西。",
|
|
62
|
+
"chapter.narrative.expansion": "这段时间提交最密,平均每周 {per_week} 次。功能在铺开,边角也在变多。",
|
|
63
|
+
"chapter.narrative.refactor": "删掉 {deletions} 行、新增 {insertions} 行 —— 典型的拆了重装。有人在还技术债。",
|
|
64
|
+
"chapter.narrative.firefight": "{fix_share} 的提交在修东西。这段历史的主题是「先让它跑起来」。",
|
|
65
|
+
"chapter.narrative.steady": "节奏慢了下来,但没停。每周 {per_week} 次提交,像是在收尾、打磨、补细节。",
|
|
66
|
+
"chapter.narrative.dormant": "这段时间只有 {commits} 次提交,平均每周 {per_week} 次。项目没死,但显然不是它的主场。",
|
|
67
|
+
"chapter.narrative.silence": "将近 {gap} 天没有提交。项目在等待,或者只是被搁在了一边。",
|
|
68
|
+
"chapter.narrative.renaissance": "沉寂之后重新开张。{commits} 次提交,新一轮在长出来。",
|
|
69
|
+
# ---- 彩蛋 ----
|
|
70
|
+
"fact.deepest_night.title": "最深的夜",
|
|
71
|
+
"fact.deepest_night.detail": "{date} {time},{author} 提交了「{subject}」。",
|
|
72
|
+
"fact.longest_streak.title": "最长连续作战",
|
|
73
|
+
"fact.longest_streak.detail": "连续 {days} 天都有提交,从 {start} 到 {end}。",
|
|
74
|
+
"fact.biggest_commit.title": "单条最大提交",
|
|
75
|
+
"fact.biggest_commit.detail": "{short_sha} 一次动了 {lines} 行,信息是「{subject}」。",
|
|
76
|
+
"fact.busiest_day.title": "最疯狂的一天",
|
|
77
|
+
"fact.busiest_day.detail": "{date} 一天提交 {commits} 次。",
|
|
78
|
+
"fact.final_loop.title": "final 陷阱",
|
|
79
|
+
"fact.final_loop.detail": "有 {count} 次提交信息里出现 final / 最终 / 最后一次。历史证明它们都不是。",
|
|
80
|
+
"fact.silence.title": "最长的沉默",
|
|
81
|
+
"fact.silence.detail": "从 {start} 到 {end},整整 {days} 天没有任何提交。",
|
|
82
|
+
"fact.origin.title": "原点",
|
|
83
|
+
"fact.origin.detail": "{date},{author} 写下了第一行:「{subject}」。",
|
|
84
|
+
"fact.night_owl.title": "深夜在场者",
|
|
85
|
+
"fact.night_owl.detail": "{author} 有 {share} 的提交发生在 0-6 点,共 {count} 次。",
|
|
86
|
+
# ---- 金句 ----
|
|
87
|
+
"quote.tech": "{commits} 次提交,{lines} 行代码,{days} 天。一段仍在生长的历史。",
|
|
88
|
+
"quote.roast": "{days} 天里提交了 {commits} 次,删了 {deletions} 行自己上周写的代码。成长就是这样。",
|
|
89
|
+
"kind.feat": "功能",
|
|
90
|
+
"kind.fix": "修复",
|
|
91
|
+
"kind.refactor": "重构",
|
|
92
|
+
"kind.docs": "文档",
|
|
93
|
+
"kind.test": "测试",
|
|
94
|
+
"kind.chore": "杂务",
|
|
95
|
+
"kind.build": "构建",
|
|
96
|
+
"kind.style": "格式",
|
|
97
|
+
"kind.perf": "性能",
|
|
98
|
+
"kind.merge": "合并",
|
|
99
|
+
"kind.revert": "回滚",
|
|
100
|
+
"kind.other": "其他",
|
|
101
|
+
# ---- 事件标签 ----
|
|
102
|
+
"event.bulk_import": "批量导入",
|
|
103
|
+
"event.deps": "依赖变更",
|
|
104
|
+
"event.big_commit": "大改动",
|
|
105
|
+
"event.revert": "回滚",
|
|
106
|
+
"event.chapter_start": "起点",
|
|
107
|
+
|
|
108
|
+
"ui.days": "{n} 天",
|
|
109
|
+
"ui.commits_n": "{n} 次提交",
|
|
110
|
+
"ui.stat.commits": "提交",
|
|
111
|
+
"ui.stat.added": "新增",
|
|
112
|
+
"ui.stat.removed": "删除",
|
|
113
|
+
"ui.stat.authors": "贡献者",
|
|
114
|
+
"ui.stat.active_days": "活跃天数",
|
|
115
|
+
"ui.stat.net": "净增",
|
|
116
|
+
"ui.stat.added_lines": "新增行",
|
|
117
|
+
"ui.stat.share_of_repo": "占全仓库",
|
|
118
|
+
"ui.export.btn": "导出分享卡 PNG",
|
|
119
|
+
"ui.export.note": "720 × 1080,适合直接发朋友圈",
|
|
120
|
+
"ui.export.generating": "正在生成…",
|
|
121
|
+
"ui.export.blocked": "当前浏览器不允许导出,请直接截图",
|
|
122
|
+
"ui.export.done": "已保存 {name}",
|
|
123
|
+
"ui.project.title_suffix": "项目演进编年史",
|
|
124
|
+
"ui.author.title_suffix": "开发者画像",
|
|
125
|
+
"ui.project.eyebrow": "项目演进编年史 · project chronicle",
|
|
126
|
+
"ui.project.s1.eyebrow": "01 / 编年史",
|
|
127
|
+
"ui.project.s1.title": "这段历史被切成 {n} 个阶段",
|
|
128
|
+
"ui.project.s1.lead": "阶段边界由提交频次与代码波动量的突变点决定,不是随手划的。同样的仓库跑两次,边界一样。",
|
|
129
|
+
"ui.chapter.cadence": "节奏",
|
|
130
|
+
"ui.chapter.cadence_value": "{v}/周",
|
|
131
|
+
"ui.chapter.fix_share": "修复占比",
|
|
132
|
+
"ui.chapter.battleground": "主战场",
|
|
133
|
+
"ui.chapter.nodes": "节点",
|
|
134
|
+
"ui.chapters.empty": "提交太少,无法切分章节。",
|
|
135
|
+
"ui.project.s2.eyebrow": "02 / 节奏",
|
|
136
|
+
"ui.project.s2.title": "代码量波动",
|
|
137
|
+
"ui.project.s2.lead": "上面是每一周的增删行,下面是提交频次。两条曲线不重合的地方,往往是「改得多但提交少」的大动作。",
|
|
138
|
+
"ui.legend.added": "新增行",
|
|
139
|
+
"ui.legend.removed": "删除行",
|
|
140
|
+
"ui.project.s3.eyebrow": "03 / 作息",
|
|
141
|
+
"ui.project.s3.title": "你什么时候写代码",
|
|
142
|
+
"ui.project.s3.lead": "按提交者本地时区统计,深色格子代表那个小时提交更密集。",
|
|
143
|
+
"ui.rhythm.night": "深夜(0–6 点)",
|
|
144
|
+
"ui.rhythm.weekend": "周末",
|
|
145
|
+
"ui.rhythm.peak_window": "最活跃时段",
|
|
146
|
+
"ui.rhythm.peak_hour": "峰值小时",
|
|
147
|
+
"ui.rhythm.peak_hour_value": "{n} 次",
|
|
148
|
+
"ui.project.s4.eyebrow": "04 / 风险",
|
|
149
|
+
"ui.project.s4.title": "文件修罗场",
|
|
150
|
+
"ui.project.s4.lead": "不只看改得多不多,还看改动里混着多少修复、以及是不是只有一个人敢动它。",
|
|
151
|
+
"ui.churn.changes": "{n} 次变更",
|
|
152
|
+
"ui.churn.authors": "{n} 人碰过",
|
|
153
|
+
"ui.churn.fix_share": "修复占比 {p}%",
|
|
154
|
+
"ui.project.s5.eyebrow": "05 / 构成",
|
|
155
|
+
"ui.project.s5.title": "代码构成",
|
|
156
|
+
"ui.project.s5.lead": "按增删行数加权,不是文件个数。一个仓库里文档比代码多,本身也是个事实。",
|
|
157
|
+
"ui.lang.other": "其他",
|
|
158
|
+
"ui.langs.empty": "没有可统计的文件类型。",
|
|
159
|
+
"ui.project.s6.eyebrow": "06 / 人",
|
|
160
|
+
"ui.project.s6.title": "谁在写",
|
|
161
|
+
"ui.people.single": "全部 {n} 次提交来自一个人。",
|
|
162
|
+
"ui.people.lead": "作者身份按邮箱合并 —— 同一个人换过机器名也只算一个。",
|
|
163
|
+
"ui.project.s7.eyebrow": "07 / 彩蛋",
|
|
164
|
+
"ui.project.s7.title": "考古发现",
|
|
165
|
+
"ui.facts.lead": "全部由规则从提交记录里挖出来,没有一句是编的。",
|
|
166
|
+
"ui.footer.generated": "gitannals {v} · 生成于 {d}",
|
|
167
|
+
"ui.footer.project": "{c} 次代码提交 · {f} 个文件",
|
|
168
|
+
"ui.author.s1.eyebrow": "01 / 坐标",
|
|
169
|
+
"ui.author.mine": "{name} · {n} 次提交",
|
|
170
|
+
"ui.author.others": "其他人 · {n} 次提交",
|
|
171
|
+
"ui.author.first_commit": "首次提交 {d}",
|
|
172
|
+
"ui.author.last_commit": "最近提交 {d}",
|
|
173
|
+
"ui.author.per_active_day": "平均 {v} 次/活跃日",
|
|
174
|
+
"ui.author.net": "净增 {n} 行",
|
|
175
|
+
"ui.author.s2.eyebrow": "02 / 作息",
|
|
176
|
+
"ui.author.rhythm_lead": "只看你自己的提交。深色格子代表那个小时提交更密集。",
|
|
177
|
+
"ui.author.most_often": "最常在",
|
|
178
|
+
"ui.author.streak": "最长连续",
|
|
179
|
+
"ui.author.s3.eyebrow": "03 / 节奏",
|
|
180
|
+
"ui.author.cadence_lead": "每根柱子是一周。空的地方就是你不在的时候。",
|
|
181
|
+
"ui.author.longest_gap": "最长一次中断 {n} 天。",
|
|
182
|
+
"ui.author.busiest": "最疯狂的一天是 {d},做了 {n} 次提交。",
|
|
183
|
+
"ui.author.s4.eyebrow": "04 / 阶段",
|
|
184
|
+
"ui.author.phases_lead": "项目被切成这些阶段,每一段你参与了多少。",
|
|
185
|
+
"ui.author.s5.eyebrow": "05 / 战场",
|
|
186
|
+
"ui.author.dirs": "目录",
|
|
187
|
+
"ui.author.files": "文件",
|
|
188
|
+
"ui.author.s6.eyebrow": "06 / 构成",
|
|
189
|
+
"ui.author.s7.eyebrow": "07 / 人",
|
|
190
|
+
"ui.author.shared_files": "{n} 个共同文件",
|
|
191
|
+
"ui.author.s8.eyebrow": "08 / 彩蛋",
|
|
192
|
+
"chart.timeline.title": "代码增删趋势",
|
|
193
|
+
"chart.bars.title": "每周提交频次",
|
|
194
|
+
"chart.heatmap.title": "开发作息热力图",
|
|
195
|
+
"chart.heatmap.desc": "按星期与小时统计的提交分布",
|
|
196
|
+
"chart.empty": "没有可绘制的时间序列",
|
|
197
|
+
"chart.tooltip.point": "{label} · {n} 次提交 {i} / {d}",
|
|
198
|
+
"chart.tooltip.bar": "{label} · {n} 次提交",
|
|
199
|
+
"chart.tooltip.cell": "{dow} {h}:00 · {n} 次提交",
|
|
200
|
+
"chart.card.title": "分享卡",
|
|
201
|
+
"chart.card.weekly": "每周增删",
|
|
202
|
+
"chart.card.rhythm": "作息点阵 · 每格一小时",
|
|
203
|
+
"ui.warn.merges": "merge 提交占比超过 30%,代码行数统计可能偏低(合并提交默认不计 diff)。",
|
|
204
|
+
"ui.warn.bulk": "检测到 {n} 次批量导入({lines} 行),已从代码量统计中剔除 —— 多为数据集或生成物。",
|
|
205
|
+
"ui.warn.few_commits": "提交数少于 {n},章节切分和趋势判断的置信度有限。",
|
|
206
|
+
"ui.warn.short_span": "这个人的活跃区间不足 7 天,画像只能当趣闻看。",
|
|
207
|
+
"ui.warn.few_personal": "提交数少于 10,标签判定不稳定。",
|
|
208
|
+
"ui.warn.low_share": "这个人只占全仓库 {share}% 的提交。如果这其实是同一个人用了多个邮箱,用 --author \"邮箱1,邮箱2\" 合并,或在 .chronicle.toml 的 [author.aliases] 里固定下来。",
|
|
209
|
+
"ui.warn.no_key": "未找到 LLM API Key(CHRONICLE_API_KEY / DEEPSEEK_API_KEY / OPENAI_API_KEY),已使用规则叙事。",
|
|
210
|
+
"ui.warn.llm_failed": "LLM 叙事失败,已回落规则叙事:{msg}",
|
|
211
|
+
"ui.warn.default_author": "未指定 --author,默认分析提交最多的人:{who}",
|
|
212
|
+
"ui.err.no_commits": "仓库里没有提交",
|
|
213
|
+
"ui.err.need_author": "--author 不能为空",
|
|
214
|
+
"ui.err.ambiguous": "「{q}」匹配到 {n} 个人,请写得更具体",
|
|
215
|
+
"ui.err.not_found": "没找到「{q}」,仓库里的贡献者是:",
|
|
216
|
+
"ui.err.no_person_commits": "这个人没有提交",
|
|
217
|
+
# ---- 个人画像 ----
|
|
218
|
+
"author.eyebrow": "开发者画像 · developer profile",
|
|
219
|
+
"author.position": "你在仓库里的坐标",
|
|
220
|
+
"author.rhythm": "你的作息",
|
|
221
|
+
"author.cadence": "你的节奏",
|
|
222
|
+
"author.chapters": "你在每个阶段",
|
|
223
|
+
"author.footprint": "你动过的地方",
|
|
224
|
+
"author.kinds": "你在写什么",
|
|
225
|
+
"author.peers": "同路人",
|
|
226
|
+
"author.facts": "关于你的一些事实",
|
|
227
|
+
"author.absent": "这段时间你不在",
|
|
228
|
+
"author.peers.note": "按共同动过的文件数排。一起改过的文件越多,说明你们在同一个战壕里。",
|
|
229
|
+
"author.share_of_repo": "占全仓库 {share}% 的提交",
|
|
230
|
+
"persona.tag.night_owl": "深夜党",
|
|
231
|
+
"persona.tag.weekend_warrior": "周末战士",
|
|
232
|
+
"persona.tag.sprinter": "连续作战",
|
|
233
|
+
"persona.tag.firefighter": "救火队员",
|
|
234
|
+
"persona.tag.refactorer": "重构派",
|
|
235
|
+
"persona.tag.documenter": "文档工程师",
|
|
236
|
+
"persona.tag.big_bang": "大块头提交",
|
|
237
|
+
"persona.tag.micro": "小步快跑",
|
|
238
|
+
"persona.tag.anchor": "仓库顶梁柱",
|
|
239
|
+
"persona.tag.lone_wolf": "独狼",
|
|
240
|
+
"persona.tag.ghost": "偶尔出没",
|
|
241
|
+
"persona.verdict.night_owl": "{name} 的 {night}% 提交发生在凌晨。别人睡了,你在改代码。",
|
|
242
|
+
"persona.verdict.weekend_warrior": "{commits} 次提交里,{weekend}% 落在周末。",
|
|
243
|
+
"persona.verdict.sprinter": "最长连续 {streak} 天都在提交,中间没有断过。",
|
|
244
|
+
"persona.verdict.firefighter": "相当一部分提交在修东西 —— 在这个项目里,你更像是那个救火的人。",
|
|
245
|
+
"persona.verdict.refactorer": "重构类提交明显偏多。你倾向于先把它理顺,再往上加功能。",
|
|
246
|
+
"persona.verdict.documenter": "文档改动占比很高。你写下的说明,往往比代码活得久。",
|
|
247
|
+
"persona.verdict.big_bang": "平均每次提交 {churn} 行。你习惯攒一波大的,再一次性交上去。",
|
|
248
|
+
"persona.verdict.micro": "平均每次提交只有 {churn} 行,典型的小步快跑。",
|
|
249
|
+
"persona.verdict.anchor": "{commits} 次提交,占全仓库 {share}%,是这个仓库提交最多的人。",
|
|
250
|
+
"persona.verdict.lone_wolf": "{share}% 的提交都来自你,基本上是独自维护。",
|
|
251
|
+
"persona.verdict.ghost": "{days} 天里只有零散几次出现,像是路过。",
|
|
252
|
+
"persona.verdict.default": "{name} 在 {days} 天里提交了 {commits} 次,占全仓库 {share}%。",
|
|
253
|
+
"persona.quote.tech": "{commits} 次提交,+{insertions} / −{deletions} 行,在这个仓库里留下 {share}% 的历史。",
|
|
254
|
+
"persona.quote.roast": "{days} 天里提交了 {commits} 次,还删掉过自己上周写的东西。这大概就是成长。",
|
|
255
|
+
# ---- 空状态 ----
|
|
256
|
+
"empty.no_commits": "这个范围里没有提交。换一个 --since / --until 试试。",
|
|
257
|
+
"empty.single_author": "单人仓库,贡献者分布图略过。",
|
|
258
|
+
"empty.no_chapters": "提交太少,无法切分章节。报告以降级模式呈现。",
|
|
259
|
+
},
|
|
260
|
+
"en": {
|
|
261
|
+
"label.commits": "commits",
|
|
262
|
+
"label.commits_code": "code commits",
|
|
263
|
+
"label.merges": "merges",
|
|
264
|
+
"label.insertions": "insertions",
|
|
265
|
+
"label.deletions": "deletions",
|
|
266
|
+
"label.net": "net lines",
|
|
267
|
+
"label.files": "files touched",
|
|
268
|
+
"label.authors": "contributors",
|
|
269
|
+
"label.active_days": "active days",
|
|
270
|
+
"label.span_days": "span",
|
|
271
|
+
"label.since": "from",
|
|
272
|
+
"label.until": "to",
|
|
273
|
+
"unit.day": "d",
|
|
274
|
+
"unit.commit": "",
|
|
275
|
+
"unit.line": "lines",
|
|
276
|
+
"unit.person": "",
|
|
277
|
+
"unit.file": "",
|
|
278
|
+
"title.timeline": "Code churn over time",
|
|
279
|
+
"title.rhythm": "When you code",
|
|
280
|
+
"title.churn": "Churn hotspots",
|
|
281
|
+
"title.languages": "Languages",
|
|
282
|
+
"title.contributors": "Contributors",
|
|
283
|
+
"title.chapters": "Chronicle",
|
|
284
|
+
"title.milestones": "Milestones",
|
|
285
|
+
"title.fun_facts": "Fun facts",
|
|
286
|
+
"rhythm.night": "late-night commits",
|
|
287
|
+
"rhythm.weekend": "weekend commits",
|
|
288
|
+
"rhythm.peak": "peak window",
|
|
289
|
+
"rhythm.peak_value": "{weekday} {hour}:00",
|
|
290
|
+
"churn.tag.hot": "hot",
|
|
291
|
+
"churn.tag.brittle": "brittle",
|
|
292
|
+
"churn.tag.silo": "silo",
|
|
293
|
+
"churn.tag.volatile": "volatile",
|
|
294
|
+
"churn.empty": "No file crossed the threshold",
|
|
295
|
+
"chapter.summary": "{commits} commits, +{insertions} / -{deletions} lines, {authors} contributors.",
|
|
296
|
+
"chapter.summary_dirs": "Main battleground: {dirs}.",
|
|
297
|
+
"chapter.narrative.flat": "{commits} commits across {days} days. Too short to shape into phases — but everything starts here.",
|
|
298
|
+
"chapter.narrative.genesis": "It started on {start}. {commits} commits turned an idea into something that runs.",
|
|
299
|
+
"chapter.narrative.expansion": "The densest stretch — {per_week} commits per week. Features spread out, and so did the corners.",
|
|
300
|
+
"chapter.narrative.refactor": "{deletions} lines removed, {insertions} added. Someone was paying down debt.",
|
|
301
|
+
"chapter.narrative.firefight": "{fix_share} of commits were fixes. The theme here was 'make it run first'.",
|
|
302
|
+
"chapter.narrative.steady": "Slower, but not stopped. {per_week} commits a week — polishing, trimming, closing loops.",
|
|
303
|
+
"chapter.narrative.dormant": "Only {commits} commits here, about {per_week} a week. Not dead, but clearly not the main stage.",
|
|
304
|
+
"chapter.narrative.silence": "Nearly {gap} days without a commit. The project was waiting, or set aside.",
|
|
305
|
+
"chapter.narrative.renaissance": "Back from silence. {commits} commits, a new layer growing.",
|
|
306
|
+
"fact.deepest_night.title": "The deepest night",
|
|
307
|
+
"fact.deepest_night.detail": "{date} {time} — {author} pushed \"{subject}\".",
|
|
308
|
+
"fact.longest_streak.title": "Longest streak",
|
|
309
|
+
"fact.longest_streak.detail": "{days} consecutive days of commits, {start} to {end}.",
|
|
310
|
+
"fact.biggest_commit.title": "Biggest single commit",
|
|
311
|
+
"fact.biggest_commit.detail": "{short_sha} moved {lines} lines at once — \"{subject}\".",
|
|
312
|
+
"fact.busiest_day.title": "Busiest day",
|
|
313
|
+
"fact.busiest_day.detail": "{commits} commits on {date}.",
|
|
314
|
+
"fact.final_loop.title": "The 'final' trap",
|
|
315
|
+
"fact.final_loop.detail": "{count} commits claimed to be final. History disagrees.",
|
|
316
|
+
"fact.silence.title": "The longest silence",
|
|
317
|
+
"fact.silence.detail": "{days} days with zero commits, {start} to {end}.",
|
|
318
|
+
"fact.origin.title": "The origin",
|
|
319
|
+
"fact.origin.detail": "On {date}, {author} wrote the first line — \"{subject}\".",
|
|
320
|
+
"fact.night_owl.title": "Night owl",
|
|
321
|
+
"fact.night_owl.detail": "{share} of {author}'s commits landed between midnight and 6am ({count} total).",
|
|
322
|
+
"quote.tech": "{commits} commits, {lines} lines, {days} days. A history still growing.",
|
|
323
|
+
"quote.roast": "{commits} commits in {days} days, and {deletions} lines deleted — code they wrote last week. That's growth.",
|
|
324
|
+
"kind.feat": "feature",
|
|
325
|
+
"kind.fix": "fix",
|
|
326
|
+
"kind.refactor": "refactor",
|
|
327
|
+
"kind.docs": "docs",
|
|
328
|
+
"kind.test": "test",
|
|
329
|
+
"kind.chore": "chore",
|
|
330
|
+
"kind.build": "build",
|
|
331
|
+
"kind.style": "style",
|
|
332
|
+
"kind.perf": "perf",
|
|
333
|
+
"kind.merge": "merge",
|
|
334
|
+
"kind.revert": "revert",
|
|
335
|
+
"kind.other": "other",
|
|
336
|
+
"event.bulk_import": "bulk import",
|
|
337
|
+
"event.deps": "deps change",
|
|
338
|
+
"event.big_commit": "big change",
|
|
339
|
+
"event.revert": "revert",
|
|
340
|
+
"event.chapter_start": "start",
|
|
341
|
+
|
|
342
|
+
"ui.days": "{n} days",
|
|
343
|
+
"ui.commits_n": "{n} commits",
|
|
344
|
+
"ui.stat.commits": "commits",
|
|
345
|
+
"ui.stat.added": "added",
|
|
346
|
+
"ui.stat.removed": "removed",
|
|
347
|
+
"ui.stat.authors": "contributors",
|
|
348
|
+
"ui.stat.active_days": "active days",
|
|
349
|
+
"ui.stat.net": "net",
|
|
350
|
+
"ui.stat.added_lines": "lines added",
|
|
351
|
+
"ui.stat.share_of_repo": "share",
|
|
352
|
+
"ui.export.btn": "Export share card",
|
|
353
|
+
"ui.export.note": "720 × 1080, ready to share",
|
|
354
|
+
"ui.export.generating": "Rendering…",
|
|
355
|
+
"ui.export.blocked": "This browser blocked the export — take a screenshot instead",
|
|
356
|
+
"ui.export.done": "Saved {name}",
|
|
357
|
+
"ui.warn.merges": "Merges exceed 30% of commits; line counts may be underestimated (merges carry no diff by default).",
|
|
358
|
+
"ui.warn.bulk": "{n} bulk imports detected ({lines} lines) and excluded from line counts — usually datasets or generated files.",
|
|
359
|
+
"ui.warn.few_commits": "Fewer than {n} commits; phase boundaries and trends are low-confidence.",
|
|
360
|
+
"ui.warn.short_span": "Active window under 7 days — treat this profile as trivia.",
|
|
361
|
+
"ui.warn.few_personal": "Fewer than 10 commits; the style tags are unreliable.",
|
|
362
|
+
"ui.warn.low_share": "This person accounts for only {share}% of commits. If it's one person with several emails, merge them with --author \"a@x,b@y\" or pin them in [author.aliases] of .chronicle.toml.",
|
|
363
|
+
"ui.warn.no_key": "No LLM API key found (CHRONICLE_API_KEY / DEEPSEEK_API_KEY / OPENAI_API_KEY) — fell back to rule-based narration.",
|
|
364
|
+
"ui.warn.llm_failed": "LLM narration failed, fell back to rules: {msg}",
|
|
365
|
+
"ui.warn.default_author": "No --author given; defaulting to the top committer: {who}",
|
|
366
|
+
"ui.err.no_commits": "No commits in this repository",
|
|
367
|
+
"ui.err.need_author": "--author cannot be empty",
|
|
368
|
+
"ui.err.ambiguous": "\"{q}\" matches {n} people — please be more specific",
|
|
369
|
+
"ui.err.not_found": "No match for \"{q}\". Contributors in this repository:",
|
|
370
|
+
"ui.err.no_person_commits": "This person has no commits",
|
|
371
|
+
"ui.project.title_suffix": "project chronicle",
|
|
372
|
+
"ui.author.title_suffix": "developer profile",
|
|
373
|
+
"ui.project.eyebrow": "project chronicle",
|
|
374
|
+
"ui.project.s1.eyebrow": "01 / chronicle",
|
|
375
|
+
"ui.project.s1.title": "This history splits into {n} phases",
|
|
376
|
+
"ui.project.s1.lead": "Phase boundaries come from change-point detection over commit cadence and code churn — not drawn by hand. Same repo, same boundaries, every run.",
|
|
377
|
+
"ui.chapter.cadence": "cadence",
|
|
378
|
+
"ui.chapter.cadence_value": "{v}/wk",
|
|
379
|
+
"ui.chapter.fix_share": "fix share",
|
|
380
|
+
"ui.chapter.battleground": "battleground",
|
|
381
|
+
"ui.chapter.nodes": "nodes",
|
|
382
|
+
"ui.chapters.empty": "Too few commits to segment.",
|
|
383
|
+
"ui.project.s2.eyebrow": "02 / cadence",
|
|
384
|
+
"ui.project.s2.title": "Code churn over time",
|
|
385
|
+
"ui.project.s2.lead": "Weekly insertions and deletions on top, commit frequency below. Where the two disagree, something big landed in few commits.",
|
|
386
|
+
"ui.legend.added": "insertions",
|
|
387
|
+
"ui.legend.removed": "deletions",
|
|
388
|
+
"ui.project.s3.eyebrow": "03 / hours",
|
|
389
|
+
"ui.project.s3.title": "When the code got written",
|
|
390
|
+
"ui.project.s3.lead": "Counted in each author's local timezone. Darker cells mean a busier hour.",
|
|
391
|
+
"ui.rhythm.night": "late night (0–6)",
|
|
392
|
+
"ui.rhythm.weekend": "weekends",
|
|
393
|
+
"ui.rhythm.peak_window": "peak window",
|
|
394
|
+
"ui.rhythm.peak_hour": "peak hour",
|
|
395
|
+
"ui.rhythm.peak_hour_value": "{n} commits",
|
|
396
|
+
"ui.project.s4.eyebrow": "04 / risk",
|
|
397
|
+
"ui.project.s4.title": "Churn hotspots",
|
|
398
|
+
"ui.project.s4.lead": "Not just how often a file changes, but how many of those changes were repairs — and whether only one person dares touch it.",
|
|
399
|
+
"ui.churn.changes": "{n} changes",
|
|
400
|
+
"ui.churn.authors": "{n} authors",
|
|
401
|
+
"ui.churn.fix_share": "fix share {p}%",
|
|
402
|
+
"ui.project.s5.eyebrow": "05 / makeup",
|
|
403
|
+
"ui.project.s5.title": "What it's made of",
|
|
404
|
+
"ui.project.s5.lead": "Weighted by line churn, not file count. A repo with more docs than code is a fact worth stating.",
|
|
405
|
+
"ui.lang.other": "other",
|
|
406
|
+
"ui.langs.empty": "No file types to count.",
|
|
407
|
+
"ui.project.s6.eyebrow": "06 / people",
|
|
408
|
+
"ui.project.s6.title": "Who wrote it",
|
|
409
|
+
"ui.people.single": "All {n} commits come from a single person.",
|
|
410
|
+
"ui.people.lead": "Identities are merged by email — the same person on a different machine still counts once.",
|
|
411
|
+
"ui.project.s7.eyebrow": "07 / trivia",
|
|
412
|
+
"ui.project.s7.title": "Archaeology",
|
|
413
|
+
"ui.facts.lead": "Mined from the commit log by rules. Nothing here is invented.",
|
|
414
|
+
"ui.footer.generated": "gitannals {v} · generated {d}",
|
|
415
|
+
"ui.footer.project": "{c} code commits · {f} files",
|
|
416
|
+
"ui.author.s1.eyebrow": "01 / position",
|
|
417
|
+
"ui.author.mine": "{name} · {n} commits",
|
|
418
|
+
"ui.author.others": "others · {n} commits",
|
|
419
|
+
"ui.author.first_commit": "first commit {d}",
|
|
420
|
+
"ui.author.last_commit": "last commit {d}",
|
|
421
|
+
"ui.author.per_active_day": "{v} per active day",
|
|
422
|
+
"ui.author.net": "net +{n} lines",
|
|
423
|
+
"ui.author.s2.eyebrow": "02 / hours",
|
|
424
|
+
"ui.author.rhythm_lead": "Only your commits. Darker cells mean a busier hour.",
|
|
425
|
+
"ui.author.most_often": "most often at",
|
|
426
|
+
"ui.author.streak": "longest streak",
|
|
427
|
+
"ui.author.s3.eyebrow": "03 / cadence",
|
|
428
|
+
"ui.author.cadence_lead": "One bar per week. The gaps are when you weren't there.",
|
|
429
|
+
"ui.author.longest_gap": "Longest gap: {n} days.",
|
|
430
|
+
"ui.author.busiest": "Busiest day was {d}, with {n} commits.",
|
|
431
|
+
"ui.author.s4.eyebrow": "04 / phases",
|
|
432
|
+
"ui.author.phases_lead": "The project, phase by phase — and how much of each was you.",
|
|
433
|
+
"ui.author.s5.eyebrow": "05 / footprint",
|
|
434
|
+
"ui.author.dirs": "directories",
|
|
435
|
+
"ui.author.files": "files",
|
|
436
|
+
"ui.author.s6.eyebrow": "06 / makeup",
|
|
437
|
+
"ui.author.s7.eyebrow": "07 / people",
|
|
438
|
+
"ui.author.shared_files": "{n} shared files",
|
|
439
|
+
"ui.author.s8.eyebrow": "08 / trivia",
|
|
440
|
+
"chart.timeline.title": "Insertions and deletions",
|
|
441
|
+
"chart.bars.title": "Commits per week",
|
|
442
|
+
"chart.heatmap.title": "Commit rhythm",
|
|
443
|
+
"chart.heatmap.desc": "Commits by weekday and hour",
|
|
444
|
+
"chart.empty": "Nothing to plot",
|
|
445
|
+
"chart.tooltip.point": "{label} · {n} commits {i} / {d}",
|
|
446
|
+
"chart.tooltip.bar": "{label} · {n} commits",
|
|
447
|
+
"chart.tooltip.cell": "{dow} {h}:00 · {n} commits",
|
|
448
|
+
"chart.card.title": "Share card",
|
|
449
|
+
"chart.card.weekly": "weekly churn",
|
|
450
|
+
"chart.card.rhythm": "rhythm · one cell per hour",
|
|
451
|
+
"author.eyebrow": "developer profile",
|
|
452
|
+
"author.position": "Where you sit in this repo",
|
|
453
|
+
"author.rhythm": "Your hours",
|
|
454
|
+
"author.cadence": "Your cadence",
|
|
455
|
+
"author.chapters": "You, by phase",
|
|
456
|
+
"author.footprint": "Where you worked",
|
|
457
|
+
"author.kinds": "What you wrote",
|
|
458
|
+
"author.peers": "Teammates",
|
|
459
|
+
"author.facts": "Some facts about you",
|
|
460
|
+
"author.absent": "You were absent here",
|
|
461
|
+
"author.peers.note": "Ranked by shared files — the more you both touched, the same trench you were in.",
|
|
462
|
+
"author.share_of_repo": "{share}% of all commits",
|
|
463
|
+
"persona.tag.night_owl": "night owl",
|
|
464
|
+
"persona.tag.weekend_warrior": "weekend warrior",
|
|
465
|
+
"persona.tag.sprinter": "streak runner",
|
|
466
|
+
"persona.tag.firefighter": "firefighter",
|
|
467
|
+
"persona.tag.refactorer": "refactorer",
|
|
468
|
+
"persona.tag.documenter": "documenter",
|
|
469
|
+
"persona.tag.big_bang": "big-bang commits",
|
|
470
|
+
"persona.tag.micro": "small steps",
|
|
471
|
+
"persona.tag.anchor": "load-bearing",
|
|
472
|
+
"persona.tag.lone_wolf": "lone wolf",
|
|
473
|
+
"persona.tag.ghost": "occasional visitor",
|
|
474
|
+
"persona.verdict.night_owl": "{night}% of {name}'s commits landed after midnight. Others slept.",
|
|
475
|
+
"persona.verdict.weekend_warrior": "{weekend}% of those {commits} commits fell on weekends.",
|
|
476
|
+
"persona.verdict.sprinter": "{streak} consecutive days of commits, unbroken.",
|
|
477
|
+
"persona.verdict.firefighter": "A large share of commits were repairs — here, you were the one putting out fires.",
|
|
478
|
+
"persona.verdict.refactorer": "Refactors run heavy. You clean it up before adding to it.",
|
|
479
|
+
"persona.verdict.documenter": "Docs take a big share. What you wrote will outlive the code.",
|
|
480
|
+
"persona.verdict.big_bang": "{churn} lines per commit on average — you save it up and land it at once.",
|
|
481
|
+
"persona.verdict.micro": "{churn} lines per commit. Classic small steps.",
|
|
482
|
+
"persona.verdict.anchor": "{commits} commits, {share}% of the repo — the top contributor here.",
|
|
483
|
+
"persona.verdict.lone_wolf": "{share}% of commits are yours — effectively solo maintenance.",
|
|
484
|
+
"persona.verdict.ghost": "A handful of appearances across {days} days.",
|
|
485
|
+
"persona.verdict.default": "{name} made {commits} commits across {days} days — {share}% of the repo.",
|
|
486
|
+
"persona.quote.tech": "{commits} commits, +{insertions} / −{deletions} lines — {share}% of this repository's history.",
|
|
487
|
+
"persona.quote.roast": "{commits} commits in {days} days, including deleting code you wrote last week. That's growth.",
|
|
488
|
+
"empty.no_commits": "No commits in this range. Try a different --since / --until.",
|
|
489
|
+
"empty.single_author": "Single-author repo, contributor chart skipped.",
|
|
490
|
+
"empty.no_chapters": "Too few commits to segment. Falling back to a flat report.",
|
|
491
|
+
},
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
# 章节原型:规则命名与 LLM 提示词共用同一套枚举,避免两边各叫各的
|
|
495
|
+
CHAPTER_ARCHETYPES: dict[str, dict[str, str]] = {
|
|
496
|
+
"genesis": {"zh": "草创破冰期", "en": "Genesis"},
|
|
497
|
+
"expansion": {"zh": "功能扩张期", "en": "Expansion"},
|
|
498
|
+
"refactor": {"zh": "重构阵痛期", "en": "The Great Refactor"},
|
|
499
|
+
"firefight": {"zh": "救火期", "en": "Firefighting"},
|
|
500
|
+
"steady": {"zh": "稳态迭代期", "en": "Steady Iteration"},
|
|
501
|
+
"dormant": {"zh": "低活跃期", "en": "Low Tide"},
|
|
502
|
+
"silence": {"zh": "沉寂期", "en": "Dormant"},
|
|
503
|
+
"renaissance": {"zh": "二次创业期", "en": "Second Wind"},
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
def t(key: str, lang: str = "zh", **kwargs: Any) -> str:
|
|
508
|
+
"""取词条并格式化。缺失的 key 原样返回,方便早期开发时发现问题。"""
|
|
509
|
+
table = TEXT.get(lang) or TEXT["zh"]
|
|
510
|
+
template = table.get(key) or TEXT["zh"].get(key) or key
|
|
511
|
+
if kwargs:
|
|
512
|
+
try:
|
|
513
|
+
return template.format(**kwargs)
|
|
514
|
+
except (KeyError, IndexError):
|
|
515
|
+
return template
|
|
516
|
+
return template
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
WEEKDAYS: dict[str, tuple[str, ...]] = {
|
|
520
|
+
"zh": ("周一", "周二", "周三", "周四", "周五", "周六", "周日"),
|
|
521
|
+
"en": ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"),
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
def weekdays(lang: str = "zh") -> tuple[str, ...]:
|
|
526
|
+
return WEEKDAYS.get(lang, WEEKDAYS["zh"])
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def chapter_archetypes(lang: str = "zh") -> dict[str, str]:
|
|
530
|
+
return {key: names.get(lang) or names["zh"] for key, names in CHAPTER_ARCHETYPES.items()}
|