Skip to content

Commit 61cbe58

Browse files
committed
feat: Git hook translate
--story=1
1 parent 0fb8f5a commit 61cbe58

File tree

6 files changed

+301
-49
lines changed

6 files changed

+301
-49
lines changed

.codei18n/mappings.json

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
"en": "// If file doesn't exist, we start with empty mapping (initialized in NewStore)",
5656
"zh-CN": "// 如果文件不存在,我们从空映射开始(在 NewStore 中初始化)"
5757
},
58+
"1100deea685325780dd3995ea189d29d9fa1a810": {
59+
"en": "// [MOCK zh-CN-\u003een] // The comment is in the local language (Chinese), stored as LocalLanguage",
60+
"zh-CN": "// [MOCK zh-CN-\u003een] // 注释是本地语言(中文),存储为 LocalLanguage"
61+
},
5862
"1212027339bde3555270d9d66713c0003eaaf405": {
5963
"en": "// Config represents the project configuration",
6064
"zh-CN": "// Config 代表项目配置"
@@ -67,6 +71,10 @@
6771
"en": "// Find source text (from source lang)",
6872
"zh-CN": "// 查找源文本(从源语言)"
6973
},
74+
"18ac95d3342afd648223a8aed8bdd09bea0f5d58": {
75+
"en": "// [MOCK zh-CN-\u003een] // ContainsChinese Checks if the text contains Chinese characters",
76+
"zh-CN": "// [MOCK zh-CN-\u003een] // ContainsChinese 检查文本是否包含中文字符"
77+
},
7078
"18bc0f35258b2889ac9adbe4465d1e197d6234bf": {
7179
"en": "// import, const, type, var",
7280
"zh-CN": "// import, const, type, var"
@@ -75,6 +83,10 @@
7583
"en": "// These should go to stderr",
7684
"zh-CN": "// 这些应该输出到 stderr"
7785
},
86+
"1954fba125c46489ae500ace78288a04eef9c998": {
87+
"en": "// Priority: config file \u003e environment variable",
88+
"zh-CN": "// 优先级:配置文件 \u003e 环境变量"
89+
},
7890
"1afad503b1b83bac4c797cc9faf0f18817f84bc3": {
7991
"en": "// read in environment variables that match",
8092
"zh-CN": "// 读取匹配的环境变量"
@@ -99,6 +111,10 @@
99111
"en": "// Currently stored in map",
100112
"zh-CN": "// 当前存储在 map 中"
101113
},
114+
"1cc70f582d6b60d9702131c584b9174e7a0d5177": {
115+
"en": "// Compare normalized texts to avoid unnecessary replacements",
116+
"zh-CN": "// 比较规范化文本以避免不必要的替换"
117+
},
102118
"1d1109dd05b83aa1467d347b21ff0af3f9123122": {
103119
"en": "// TranslateBatch translates a batch of texts",
104120
"zh-CN": "// TranslateBatch 翻译一批文本"
@@ -123,6 +139,10 @@
123139
"en": "// Translator defines the interface for translation services",
124140
"zh-CN": "// Translator 定义了翻译服务的接口"
125141
},
142+
"2137b3eacf7bca7ba849446a033f36f1def8e439": {
143+
"en": "// Auto-detect DeepSeek URL if not set",
144+
"zh-CN": "// 如果未设置,则自动检测 DeepSeek URL"
145+
},
126146
"21d5787be5da6ab1088e2bb7755d503e0f305bbf": {
127147
"en": "// Create hook content",
128148
"zh-CN": "// 创建钩子内容"
@@ -131,6 +151,14 @@
131151
"en": "// Remove block markers",
132152
"zh-CN": "// 移除区块标记"
133153
},
154+
"22b95b0c1fd5dba1c42b0e7ded7fd9c95c3df3aa": {
155+
"en": "// Debug config loading",
156+
"zh-CN": "// 调试配置加载"
157+
},
158+
"256f10689dd1551d6708e2e5468a73a636f38dd1": {
159+
"en": "// Case 2: ZH exists, EN missing -\u003e Translate ZH to EN (reverse translation)",
160+
"zh-CN": "// 情况2:存在ZH,缺少EN -\u003e 将ZH翻译为EN(反向翻译)"
161+
},
134162
"25b1fa5b96bc9e163b48f7ffbb25d24775c7fd39": {
135163
"en": "// Skipping strict assertion for MVP",
136164
"zh-CN": "// 为最小可行产品跳过严格断言"
@@ -139,6 +167,14 @@
139167
"en": "// Apply replacements in reverse order",
140168
"zh-CN": "// 按相反顺序应用替换"
141169
},
170+
"269c2d7efdaab3cff9240bb6b79ceaac70d918f6": {
171+
"en": "// [MOCK zh-CN-\u003een] // IsEnglish determines if the text is primarily in English",
172+
"zh-CN": "// [MOCK zh-CN-\u003een] // IsEnglish 判断文本是否主要是英文"
173+
},
174+
"26b78823baa37787dff89b487c53252e2234fd95": {
175+
"en": "// Supports fully lowercase baseurl",
176+
"zh-CN": "// 支持全小写的 baseurl"
177+
},
142178
"2706578c0b650981533d8d2cbdcfeecb8e5893d3": {
143179
"en": "// TextRange represents the range of text in the source code (1-based)",
144180
"zh-CN": "// TextRange 表示源代码中的文本范围(基于1的索引)"
@@ -147,6 +183,10 @@
147183
"en": "// Block comment /* */",
148184
"zh-CN": "// 块注释 /* */"
149185
},
186+
"2aa5b10fd959f6d7a34647fca6b0bb705129c105": {
187+
"en": "// - If zh-CN exists but en is missing: zh-CN -\u003e en",
188+
"zh-CN": "// - 如果 zh-CN 存在而 en 缺失:zh-CN -\u003e en"
189+
},
150190
"2b5d30d04a8c0d6887a4374e1782d0d23b233eea": {
151191
"en": "// Get returns the translation for a specific comment ID and language",
152192
"zh-CN": "// 根据特定评论ID和语言返回对应的翻译内容"
@@ -207,6 +247,10 @@
207247
"en": "// or better: log.Warn",
208248
"zh-CN": "// 或者更好的做法:log.Warn"
209249
},
250+
"374d313154d1916836ca8871590bce2d8c7644f3": {
251+
"en": "// [MOCK zh-CN-\u003een] // IsChinese determines if the text is primarily in Chinese",
252+
"zh-CN": "// [MOCK zh-CN-\u003een] // IsChinese 判断文本是否主要是中文"
253+
},
210254
"395803016192d38bc32a244c7b5a92ce70c4f2cc": {
211255
"en": "// Check if target lang exists and is not empty",
212256
"zh-CN": "// 检查目标语言是否存在且不为空"
@@ -251,6 +295,10 @@
251295
"en": "// Model overrides? We need to verify if provider supports model config",
252296
"zh-CN": "// 模型覆盖?我们需要验证提供商是否支持模型配置"
253297
},
298+
"3dea53174d002c267c58c6cbea241d3e4db70a0a": {
299+
"en": "// 2. Translate missing English translations",
300+
"zh-CN": "// 2. 翻译缺失的英文翻译"
301+
},
254302
"3e014085442741b738242f1204f9a8f4e9dda404": {
255303
"en": "// Stdout only",
256304
"zh-CN": "// 仅输出到标准输出"
@@ -259,6 +307,10 @@
259307
"en": "// But let's try a simple loop here. Ideally, `translate` command handles concurrency.",
260308
"zh-CN": "// 但这里我们尝试一个简单的循环。理想情况下,`translate` 命令应处理并发。"
261309
},
310+
"3fb05fc32456cad97b8ea55504799ed4d8d7501a": {
311+
"en": "// Default DeepSeek base",
312+
"zh-CN": "// 默认的 DeepSeek 基础模型"
313+
},
262314
"414d032a864ca642e0e7d600a12922c34b14198a": {
263315
"en": "// This test is manual verification mainly, but ensures compilation and basic function availability",
264316
"zh-CN": "// 本测试主要进行人工验证,但确保编译和基本功能可用性"
@@ -267,6 +319,10 @@
267319
"en": "// 3. Translate (Mock)",
268320
"zh-CN": "// 3. 翻译(模拟)"
269321
},
322+
"437ef043134b58a2c4f88530bc8a8ff08d2e5d19": {
323+
"en": "// Basic check to see if it looks like Chinese (or at least changed)",
324+
"zh-CN": "// 基础检查,判断是否看起来像中文(或至少已更改)"
325+
},
270326
"447728161213707c064a616adc9a26f319449a52": {
271327
"en": "// Rule: SHA1(file_path + language + symbol + normalized_text)",
272328
"zh-CN": "// 规则:SHA1(文件路径 + 语言 + 符号 + 规范化文本)"
@@ -319,6 +375,10 @@
319375
"en": "// Translate translates the text from source language to target language",
320376
"zh-CN": "// Translate 将文本从源语言翻译为目标语言"
321377
},
378+
"58906e3f950e015df4deb60072cc41ca33797142": {
379+
"en": "// It runs only if OPENAI_API_KEY is set.",
380+
"zh-CN": "// 仅当设置了 OPENAI_API_KEY 时才会运行。"
381+
},
322382
"5891c9d1ad7df76e562dd1bc339051d61cd9e42a": {
323383
"en": "// TextRange represents the position of text in the source file",
324384
"zh-CN": "// TextRange 表示文本在源文件中的位置"
@@ -327,6 +387,14 @@
327387
"en": "// Determine strategy",
328388
"zh-CN": "// 确定策略"
329389
},
390+
"5a7adb029281a1a578262900b2e3858e677bf683": {
391+
"en": "// Normalize current comment text for comparison",
392+
"zh-CN": "// 标准化当前评论文本以便比较"
393+
},
394+
"5a8dccb8f5357ef0c5b9fe87545b698d3636e8da": {
395+
"en": "// Restore Mode: ZH -\u003e EN",
396+
"zh-CN": "// 恢复模式:ZH -\u003e EN"
397+
},
330398
"5b7c0f7ef9ae77a1ef3024c07c9e192ee4e44fed": {
331399
"en": "// End column number",
332400
"zh-CN": "// 结束列号"
@@ -359,6 +427,10 @@
359427
"en": "// assert.Contains(t, string(mapFile), \"MOCK en-\u003ezh-CN\") ",
360428
"zh-CN": "// 断言 mapFile 字符串包含 \"MOCK en-\u003ezh-CN\""
361429
},
430+
"638b157a9a626c27088d8615e6fc34cb764015d8": {
431+
"en": "// [MOCK zh-CN-\u003een] // Check if it contains Chinese characters (CJK Unified Ideographs)",
432+
"zh-CN": "// [MOCK zh-CN-\u003een] // 检查是否包含中文字符(CJK 统一汉字)"
433+
},
362434
"645801cb7301eddf23186b0403d22a4b65fddfe4": {
363435
"en": "// 4. Verify Mapping Content",
364436
"zh-CN": "// 4. 验证映射内容"
@@ -375,6 +447,10 @@
375447
"en": "// Standard loggers that write to Stderr",
376448
"zh-CN": "// 标准日志记录器,将日志写入 Stderr"
377449
},
450+
"694c14146be78106d0973a2c7e8d2c9a1d7051f2": {
451+
"en": "// Current text is likely in LocalLanguage (ZH)",
452+
"zh-CN": "// 当前文本很可能为本地语言(ZH)"
453+
},
378454
"697d783d780d116ba66b2ec81c188734c6940523": {
379455
"en": "// Start line number",
380456
"zh-CN": "// 起始行号"
@@ -443,6 +519,10 @@
443519
"en": "// Default target",
444520
"zh-CN": "// 默认目标"
445521
},
522+
"795d186212934c9e0d9e295589759d694ef3e65a": {
523+
"en": "// Case 1: EN exists, ZH missing -\u003e Translate EN to ZH",
524+
"zh-CN": "// 情况1:EN存在,ZH缺失 -\u003e 将EN翻译为ZH"
525+
},
446526
"79a15c5590a733d0b626a0f894d9b2b8f1893e45": {
447527
"en": "// Type is the type of the comment",
448528
"zh-CN": "// Type 是评论的类型"
@@ -471,6 +551,10 @@
471551
"en": "// Use scope tracking to find comment symbols",
472552
"zh-CN": "// 使用作用域追踪来查找注释符号"
473553
},
554+
"81400e673eca70fe74d5af7769f0536b206e846e": {
555+
"en": "// [MOCK zh-CN-\u003een] // Intelligently detect comment language",
556+
"zh-CN": "// [MOCK zh-CN-\u003een] // 智能检测注释语言"
557+
},
474558
"82cb47e0f4105416f7bda59d18f9605871752c28": {
475559
"en": "// The contracts/cli_commands.md says:",
476560
"zh-CN": "// contracts/cli_commands.md 文件说明:"
@@ -479,6 +563,14 @@
479563
"en": "// SaveConfig writes the configuration to the .codei18n/config.json file",
480564
"zh-CN": "// SaveConfig 将配置写入 .codei18n/config.json 文件"
481565
},
566+
"83eba6f346a21ef23beb33f21cdbe28d54e95098": {
567+
"en": "// [MOCK zh-CN-\u003een] // ExtractChineseChars extracts all Chinese characters from the text",
568+
"zh-CN": "// [MOCK zh-CN-\u003een] // ExtractChineseChars 提取文本中的所有中文字符"
569+
},
570+
"84251753a7e189bda84ca6089a0089b4c0c59415": {
571+
"en": "// - If en exists but zh-CN is missing: en -\u003e zh-CN",
572+
"zh-CN": "// - 如果 en 存在而 zh-CN 缺失:en -\u003e zh-CN"
573+
},
482574
"848b2d9f898c06190a4bf5c3701ccaf0f33c6dac": {
483575
"en": "// Save writes the mapping data to the specified path",
484576
"zh-CN": "// 将映射数据保存到指定路径"
@@ -563,6 +655,10 @@
563655
"en": "// Second Level Key: Language Code (e.g., \"zh-CN\")",
564656
"zh-CN": "// 第二级键:语言代码(例如:\"zh-CN\""
565657
},
658+
"98cfcc99e776a35d152acfe2bb3de333b6678144": {
659+
"en": "// 1. Update mappings for staged files (adds new Chinese comments)",
660+
"zh-CN": "// 1. 更新暂存文件的映射(添加新的中文注释)"
661+
},
566662
"99ce360910caeb717c18acee5976098cdb1d09dc": {
567663
"en": "// Default to package level",
568664
"zh-CN": "// 默认使用包级别"
@@ -575,6 +671,10 @@
575671
"en": "// ParseComments is required to get comments in the AST",
576672
"zh-CN": "// ParseComments 是获取 AST 中注释所必需的"
577673
},
674+
"9b7cfa149530c55907f30e65d497b574649c4795": {
675+
"en": "// [MOCK zh-CN-\u003een] // Remove comment markers",
676+
"zh-CN": "// [MOCK zh-CN-\u003een] // 移除注释标记"
677+
},
578678
"9e9ff4ff1867057fb3508f8f3a3c7cee3e5c5ddf": {
579679
"en": "// Comment represents a single comment extracted from AST",
580680
"zh-CN": "// Comment 表示从抽象语法树中提取的单个注释"
@@ -735,6 +835,10 @@
735835
"en": "// Default, should be updated from config",
736836
"zh-CN": "// 默认值,应从配置中更新"
737837
},
838+
"bf8111b4e64ed571f0a78c5b6bfe88891cc02ad7": {
839+
"en": "// TestDeepSeekIntegration is a manual test to verify API connectivity.",
840+
"zh-CN": "// TestDeepSeekIntegration 是一个用于验证 API 连通性的手动测试。"
841+
},
738842
"c01ff44543bba070b9eb83bfc4a4aa2f2c8e083f": {
739843
"en": "// Load reads the mapping file from disk",
740844
"zh-CN": "// 从磁盘读取映射文件"
@@ -771,6 +875,10 @@
771875
"en": "// rootCmd represents the base command when called without any subcommands",
772876
"zh-CN": "// rootCmd 表示在没有调用任何子命令时的基础命令"
773877
},
878+
"c60ebc2ad9a0f896a97569633cca8c467aa9c450": {
879+
"en": "// 4. Re-stage modified files",
880+
"zh-CN": "// 4. 重新暂存已修改的文件"
881+
},
774882
"c6d7299f6d7a69130f541c31e164f7ebfe5c14c5": {
775883
"en": "// (Using a simple map interface for verification)",
776884
"zh-CN": "// (使用简单的映射接口进行验证)"
@@ -791,6 +899,14 @@
791899
"en": "// json.Unmarshal might fail if there is garbage",
792900
"zh-CN": "// 如果存在无效数据,json.Unmarshal 可能会失败"
793901
},
902+
"c7cd9c62b64f18e8a542ae10cb6518ab2ddaa5e4": {
903+
"en": "// [MOCK zh-CN-\u003een] // DetectLanguage detects the language of the text",
904+
"zh-CN": "// [MOCK zh-CN-\u003een] // DetectLanguage 检测文本的语言"
905+
},
906+
"ca4e65d91da4db9094cf8784da22481744f2d176": {
907+
"en": "// [MOCK zh-CN-\u003een] // Returns \"zh-CN\" if the string contains Chinese characters, otherwise returns \"en\"",
908+
"zh-CN": "// [MOCK zh-CN-\u003een] // 返回 \"zh-CN\" 如果包含中文字符,否则返回 \"en\""
909+
},
794910
"cb4d27d814fcb68b86aeb52ef42992825f2592ab": {
795911
"en": "// Validation",
796912
"zh-CN": "// 验证"
@@ -839,6 +955,14 @@
839955
"en": "// Override flags",
840956
"zh-CN": "// 覆盖标志"
841957
},
958+
"d62bfa565ca4af35ba438346d7ff295c041e3905": {
959+
"en": "// Pre-commit workflow:",
960+
"zh-CN": "// 预提交工作流:"
961+
},
962+
"d67d69dedfcab6910f34cd169a55f1e80e620341": {
963+
"en": "// Strategy: Bidirectional Translation",
964+
"zh-CN": "// 策略:双向翻译"
965+
},
842966
"d688e3c0b25b4e23a8efcb2a82ba732083d33ebd": {
843967
"en": "// Returns a map of original text to translated text",
844968
"zh-CN": "// 返回原始文本到翻译文本的映射"
@@ -895,6 +1019,14 @@
8951019
"en": "// 2. Generate IDs",
8961020
"zh-CN": "// 2. 生成ID"
8971021
},
1022+
"e1b4cd16009c220f35cdc4912354d462e79f9a5d": {
1023+
"en": "// Read optional config from env or default to DeepSeek",
1024+
"zh-CN": "// 从环境变量读取可选配置,或默认使用 DeepSeek"
1025+
},
1026+
"e20ae154784ede6f08632501a366d7152f970158": {
1027+
"en": "// 3. Convert comments to English",
1028+
"zh-CN": "// 3. 将注释转换为英文"
1029+
},
8981030
"e33546d3145a39e131e24c30db97813b4709c316": {
8991031
"en": "// ID generation works.",
9001032
"zh-CN": "// ID 生成功能正常。"
@@ -907,6 +1039,10 @@
9071039
"en": "// This is the ONLY function that should write to Stdout when using --format=json",
9081040
"zh-CN": "// 在使用 --format=json 时,这是唯一应写入标准输出的函数"
9091041
},
1042+
"e487f7759d30cfd238b777f93e9634c8bee74f9d": {
1043+
"en": "// Search in store by comparing normalized values",
1044+
"zh-CN": "// 在存储中通过比较标准化值进行搜索"
1045+
},
9101046
"e61467433643b0c97500b6106a2c879e9ab14ce0": {
9111047
"en": "// Find target text",
9121048
"zh-CN": "// 查找目标文本"
@@ -939,6 +1075,10 @@
9391075
"en": "// Restore Mode",
9401076
"zh-CN": "// 恢复模式"
9411077
},
1078+
"eb7c3c310508ec167c31dfd8a6522683be1075c6": {
1079+
"en": "// [MOCK zh-CN-\u003een] // The comment is in the source language (English), stored as SourceLanguage",
1080+
"zh-CN": "// [MOCK zh-CN-\u003een] // 注释是源语言(英文),存储为 SourceLanguage"
1081+
},
9421082
"ec17c235015c6b472539508e8a76cc6b6e6ec94f": {
9431083
"en": "// Load reads the mapping file from the specified path",
9441084
"zh-CN": "// 从指定路径读取映射文件"
@@ -1035,6 +1175,10 @@
10351175
"en": "// GetMapping returns the underlying mapping object (read-only copy recommended for complex ops)",
10361176
"zh-CN": "// GetMapping 返回底层映射对象(建议在复杂操作中使用只读副本)"
10371177
},
1178+
"fd1e99819275e88e8ce018da885b5f036a8dc5f6": {
1179+
"en": "// Case-insensitive check for baseUrl/baseURL/base_url",
1180+
"zh-CN": "// 对 baseUrl/baseURL/base_url 进行不区分大小写的检查"
1181+
},
10381182
"ffe3594d913416ff3f3770ae1ae2a968a1e724ed": {
10391183
"en": "// Mutex for counting",
10401184
"zh-CN": "// 用于计数的互斥锁"

0 commit comments

Comments
 (0)