feat(i18n): 添加中文(简体)本地化支持及 Token 用量统计#255
Open
xiaoguomeiyitian wants to merge 5 commits into
Open
Conversation
- Add src/i18n.ts with t(), I18N, isZh() APIs for TypeScript-side localization - Add package.nls.json and package.nls.zh-cn.json for VS Code extension NLS - Localize all hardcoded English strings in extension.ts, provider.ts, provideModel.ts, configView.ts, commitMessageGenerator.ts - Add data-i18n attribute markers to configView.html for WebView localization - Add complete i18n translation table (150+ entries) in configView.js with auto language detection - All UI text now displays in Chinese when VS Code language is set to zh-cn
added 2 commits
May 19, 2026 12:51
- 将HTML lang属性改为动态变量%LOCALE% - 为commitLanguage选项添加data-i18n属性支持国际化 - 新增tokenUsageEnabled配置项用于跟踪token消耗 - 优化多个字段描述文本以提高清晰度
Author
added 2 commits
May 26, 2026 11:57
- 优化 `valBothMaxTokens` 错误提示,明确建议使用 `max_completion_tokens` - 将 `tokenUsageContext` 文本从 "Token 使用量" 调整为 "上下文窗口" - 重命名 `commitGenerationFailed` 为 `commitGenFailed` 以保持命名一致 - 新增多项错误提示与配置项,包括 Git 扩展未找到、无可用仓库、SCM 仓库未找到、无变更、未配置提交模型等 - 补充默认提交提示词、图片处理相关错误提示及 Git 环境检测提示
- Anthropic API: 移除 `includeReasoningInRequest` 配置依赖,当消息历史包含思考内容时,自动在请求中包含 `thinking` 块,以满足 DeepSeek 等推理模型的要求 - OpenAI API (Chat & Responses): 移除配置检查,始终收集并传递 `reasoning_content` 或 `LanguageModelThinkingPart`,确保推理模型获得完整上下文 - Gemini API: 新增对 `LanguageModelThinkingPart` 的解析与传递,在请求中正确包含历史思考内容 - tokenUsageView: 按 promptTokens 降序排序提供商统计,优化图表尺寸 (950x300) 及 SVG 宽度设置 - i18n: 删除未使用的 `providerIdRequired2` 翻译键 - extension: 为 `generateGitCommitMessage` 命令添加 `await` 以确保异步操作完成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





feat(i18n): 添加中文(简体)本地化支持及 Token 用量统计
🇨🇳 中文说明
本 PR 引入两项主要功能:
✨ 新增内容
🌐 国际化 (i18n) 支持
新增文件:
src/i18n.ts- TypeScript 国际化工具模块package.nls.json- VS Code 英文翻译文件package.nls.zh-cn.json- VS Code 中文翻译文件新增功能:
📊 Token 用量统计系统
新增文件:
src/tokenUsage/tokenUsageTypes.ts- 数据结构定义src/tokenUsage/tokenUsageTracker.ts- 核心追踪逻辑src/tokenUsage/tokenUsageView.ts- 统计面板 WebView新增命令:
oaicopilot.showTokenUsage- 显示 Token 用量统计面板oaicopilot.resetTokenUsage- 重置所有统计数据oaicopilot.exportTokenUsage- 导出 Token 用量数据新增配置项:
oaicopilot.tokenUsageEnabled- 启用/禁用 Token 用量统计(默认:false 关闭)🔧 核心功能
1. 国际化 (i18n)
TypeScript 端
I18N.xxx()方法返回本地化文本t()函数支持双语参数isZh()判断是否为中文环境vscode.env.language自动选择语言WebView 端
lang属性使用%LOCALE%占位符(由 VS Code NLS 注入)data-i18n属性configView.js包含完整翻译表,自动检测语言并翻译VS Code 贡献点
package.json使用%displayName%、%description%、%command.*%占位符2. Token 用量统计
预聚合存储设计
统计指标
数据结构