Files
mlogclub b743639731 feat: add language support and tests for English and Chinese seed data
- Introduced a new package `seedlang` to handle language parsing and constants for English and Chinese.
- Updated `Init` functions across various modules (kb, quickreply, skill, tag) to accept a language parameter.
- Implemented English seed data for FAQs, quick replies, skills, and tags, ensuring no Chinese text is present in English data.
- Added tests to verify that English seed data does not contain Chinese characters.
- Removed outdated README file from the kb test data directory.
- Created new test files for channel and kb to validate the absence of Chinese text in English seed data.
2026-06-01 12:03:57 +08:00

26 lines
461 B
Go

package seedlang
import (
"fmt"
"strings"
)
type Language string
const (
Chinese Language = "zh"
English Language = "en"
)
func Parse(raw string) (Language, error) {
normalized := strings.ToLower(strings.TrimSpace(raw))
switch normalized {
case "", "zh", "zh-cn", "chinese":
return Chinese, nil
case "en", "en-us", "english":
return English, nil
default:
return "", fmt.Errorf("unsupported testdata language %q, supported: zh, en", raw)
}
}