项目配置
配置文件结构
项目使用 template.config.json 作为主配置文件,包含以下主要配置项:
模板信息
json
{
"template": {
"name": "项目名称",
"description": "项目描述",
"author": "作者",
"license": "MIT",
"repository": "仓库地址"
}
}语言配置
json
{
"languages": {
"language_code": {
"name": "语言名称",
"region": "地区",
"displayName": "显示名称",
"baseLanguage": "基础语言代码",
"bidirectional": false,
"rtl": false,
"enabled": true
}
}
}配置说明:
baseLanguage: 作为翻译基础的官方语言代码enabled: 是否启用该语言rtl: 是否为右到左书写bidirectional: 是否支持双向文本
资源包设置
json
{
"pack": {
"namePrefix": "资源包前缀",
"iconPath": "图标路径",
"defaultDescription": "默认描述"
}
}目录结构
json
{
"directories": {
"data": "data",
"translations": "data/translations",
"official": "data/official",
"common": "data/translations/common",
"versions": "data/translations/versions",
"config": "config",
"output": "dist/packs",
"public": "public"
}
}构建设置
json
{
"build": {
"userAgent": "用户代理",
"dateFormat": "YYMMdd",
"compressionLevel": 9
}
}CLI配置
json
{
"cli": {
"name": "cli命令名",
"description": "CLI描述",
"commands": {
"progress": "查看翻译进度",
"sync": "同步官方翻译"
}
}
}配置方法
自动初始化
bash
pnpm run init手动配置
bash
cp template.config.example.json template.config.json然后编辑配置文件内容。
配置验证
系统会自动验证配置文件的完整性和正确性。如配置有误,CLI命令会提示具体错误信息。