feat: add content filter and code processing module (v0.3.0)
- Add content filter module (internal/content/) - Implement basic character filtering (control chars, line breaks, symbols) - Implement code block and inline code detection - Implement comment detection for 30+ languages (JS/Python/Go/HTML/etc) - Add go-enry dependency for intelligent language detection - Add SkipKeywords config option (default: TODO/FIXME/HACK/XXX/etc) - Integrate content processing into Translator - Update config.yaml with skip_keywords
This commit is contained in:
39
changelog.md
39
changelog.md
@@ -32,6 +32,45 @@
|
||||
|
||||
## 版本历史
|
||||
|
||||
### 0.3.0 (2026-03-29) - 内容过滤与代码处理
|
||||
**类型**: 功能版本
|
||||
**状态**: 开发中
|
||||
|
||||
**变更内容**:
|
||||
- ✅ 添加内容过滤模块 (internal/content/)
|
||||
- ✅ 实现基础字符过滤(移除控制字符、规范化换行符、截断超长符号)
|
||||
- ✅ 实现代码块和行内代码识别
|
||||
- ✅ 实现代码注释智能识别(支持 JS/TS/Java/Python/Go/HTML 等 30+ 语言)
|
||||
- ✅ 添加 go-enry 依赖实现编程语言智能检测
|
||||
- ✅ 添加 SkipKeywords 配置项,默认保留 TODO/FIXME/HACK 等关键词不翻译
|
||||
- ✅ 集成内容处理到 Translator 模块
|
||||
|
||||
**新增文件**:
|
||||
- `internal/content/content.go` - 模块入口
|
||||
- `internal/content/filter.go` - 基础字符过滤
|
||||
- `internal/content/parser.go` - 内容解析器和语言检测
|
||||
|
||||
**配置更新**:
|
||||
- `configs/config.yaml` 新增 `skip_keywords` 配置项
|
||||
- 支持用户自定义不翻译的关键词列表
|
||||
|
||||
**使用示例**:
|
||||
```bash
|
||||
# 翻译包含代码的文档,自动识别代码和注释
|
||||
yoyo "这是一个文档 ```js // TODO: fix this ```"
|
||||
# 代码块保持不变,只翻译注释中的词汇
|
||||
# TODO: 修复这个
|
||||
```
|
||||
|
||||
**讨论记录**:
|
||||
- [内容过滤与代码处理设计](taolun.md#内容过滤与代码处理设计)
|
||||
|
||||
**下一步**:
|
||||
- 实现更多厂商(火山引擎、国家超算、Qwen、OpenAI兼容)
|
||||
- 添加配置文件路径查找机制
|
||||
- 实现配置文件迁移工具
|
||||
- 完善错误处理和用户体验
|
||||
|
||||
### 0.2.0 (2026-03-29) - 语言支持和配置向导
|
||||
**类型**: 功能版本
|
||||
**状态**: 开发中
|
||||
|
||||
Reference in New Issue
Block a user