Langparse 使用说明
安装
npm install --save-dev langparse
设置命令
在项目 package.json 的 script 中增加如下命令
"lang": "node ./node_modules/langparse/index.js"
初始化
公共配置初始化
npm run lang init
会在项目最外层生成如下文件
|-- langConfig
|-- baseConfig.js
|-- defaultConfig.js
|-- README.md
快速使用
// init 之后可执行
npm run lang
子项目 [projectName] 初始化
npm run lang init [projectName]
会在 baseConfig.js 配置好的子项目位置中创建
|-- langConfig.js
langparse 有两个使用层级,必须进行对应 init 之后才能使用
- 默认层级
npm run lang。将以 langConfig 为执行目录,使用 defaultConfig.js 作为配置
- 子项目层级
npm run lang [projectName]。将以 baseConfig.js 中配置定位到对应子目录,以子目录中的 langConfig.js 作为配置执行
配置说明
baseConfig.js
| projectDir | ./do.config.js | 指定一个文件,在此文件中,可以详细配置子项目的文件路径 |
| dirKey | langDir | 详情如下 |
| proKey | ["deploy"] | 假设根据 projectDir 读取到了配置文件 config,子项目详细目录位置为 config["deploy"][projectName][dirKey] |
| comDir | project | 如果没有获取上述值,子项目详细目录位置为 [langConfig 所在目录]/project/[projectName] |
defaultConfig.js | langConfig.js
假设有例句:this xxx still need to slash ฿xxx.xx more to get this product
| lang | ["zh_CN", "en_US", "th_TH"] | excal 中的语言顺序,同时也是输出的文件名 |
| langPre | 空 | 输出的文件名前缀 [langPre]zh_CN.js (输出会直接覆盖同名文件,请输出前自行确认) |
| langIns | true | 输出的文件是否需要增加 insert 函数 |
| entryFile | ./input.xlsx | 相对 ...Config.js 的输入文件位置 |
| outFileName | output | 相对 ...Config.js 的输出文件夹位置 |
| maxWordNum | 6 | key 值最大单词长度(不计入_) 3 => this_StillNeed... |
| insertReserved | true | 是否需要替换 xx 例1:"true" => this {0} still need to slash {1} more to get this product 例2:"false" => this xx still need to slash ฿xx.xx more to get this product |
| currencySymbol | 空 | 是否需要替换货币符,insertReserved = true 时此设置才生效 例1:"¥$฿" => this {0} still need to slash {1} more to get this product 例2:"" => this {0} still need to slash ฿{1} more to get this product |
| keyStyle | space | 命名风格 3 => this_StillNeed... 例1:"Camel" => this_StillNeedToSlash_More... 例2:"Pascal" => This_StillNeedToSlash_More... 例3:"space" => this _ still need to slash _ more... |
| preStr | 空 | 命名前缀 "[str]" => [str]this_StillNeedToSlash_More... |
注: langConfig.js 未配置的部分,会采用 defaultConfig.js 中的值。defaultConfig.js 必须配置每一项