feat: add language support and onboard configuration wizard (v0.2.0)

- Add language code intelligent parsing module (internal/lang)
- Support --lang parameter for target language specification
- Support multiple language code formats (BCP47, aliases, Chinese names)
- Implement interactive onboard configuration wizard
- Update Config struct with language fields
- Add survey library dependency for interactive UI
- Improve CLI command interface
- Add comprehensive unit tests for language module
- Update documentation (AGENTS.md, changelog.md, taolun.md, memory.md)

Supported language codes:
- Standard: zh-CN, zh-TW, en-US, en-GB, ja, ko, es, fr, de
- Aliases: cn, en, jp, kr, es, fr, de
- Chinese names: chinese, english, japanese

Commands:
- yoyo "Hello world" - basic translation
- yoyo --lang=cn "Hello world" - specify target language
- yoyo onboard - start configuration wizard
- yoyo onboard --force - force reconfiguration

Version: 0.2.0
This commit is contained in:
2026-03-29 01:30:42 +08:00
parent cd305a62ef
commit 24ba405d55
11 changed files with 1164 additions and 6 deletions

View File

@@ -12,9 +12,11 @@ import (
// Config 全局配置结构
type Config struct {
// 全局设置
DefaultProvider string `yaml:"default_provider"`
DefaultModel string `yaml:"default_model"`
Timeout int `yaml:"timeout"` // 秒
DefaultProvider string `yaml:"default_provider"`
DefaultModel string `yaml:"default_model"`
Timeout int `yaml:"timeout"` // 秒
DefaultSourceLang string `yaml:"default_source_lang"` // 默认源语言auto为自动检测
DefaultTargetLang string `yaml:"default_target_lang"` // 默认目标语言
// 厂商配置
Providers map[string]ProviderConfig `yaml:"providers"`
@@ -97,6 +99,12 @@ func (c *Config) setDefaults() {
if c.DefaultModel == "" {
c.DefaultModel = "gpt-3.5-turbo"
}
if c.DefaultSourceLang == "" {
c.DefaultSourceLang = "auto" // 自动检测
}
if c.DefaultTargetLang == "" {
c.DefaultTargetLang = "zh-CN" // 默认翻译为简体中文
}
// 为每个厂商设置默认值
for name, provider := range c.Providers {
@@ -190,6 +198,8 @@ func (c *Config) String() string {
builder.WriteString(fmt.Sprintf("DefaultProvider: %s\n", c.DefaultProvider))
builder.WriteString(fmt.Sprintf("DefaultModel: %s\n", c.DefaultModel))
builder.WriteString(fmt.Sprintf("Timeout: %d seconds\n", c.Timeout))
builder.WriteString(fmt.Sprintf("DefaultSourceLang: %s\n", c.DefaultSourceLang))
builder.WriteString(fmt.Sprintf("DefaultTargetLang: %s\n", c.DefaultTargetLang))
builder.WriteString("Providers:\n")
for name, provider := range c.Providers {
builder.WriteString(fmt.Sprintf(" %s: enabled=%v, model=%s\n", name, provider.Enabled, provider.Model))