# langparse

> parse language

Latest version **1.1.2** (published 2019-01-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install langparse
pnpm add langparse
yarn add langparse
bun add langparse
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-01-25 |
| First published | 2019-01-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 80.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | qqqqqcy |
| Keywords | langparse, 翻译 |

## Links

- npm: https://www.npmjs.com/package/langparse
- npm.io page: https://npm.io/package/langparse

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [has-flag](https://npm.io/package/has-flag.md) ^3.0.0
- [node-xlsx](https://npm.io/package/node-xlsx.md) ^0.12.1
- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^1.0.5

## Recent versions

- 1.1.2 (latest) — 2019-01-25
- 1.1.1 — 2019-01-25
- 1.1.0 — 2019-01-25
- 1.0.8 — 2019-01-22
- 1.0.7 — 2019-01-22
- 1.0.6 — 2019-01-22
- 1.0.5 — 2019-01-22
- 1.0.4 — 2019-01-22
- 1.0.3 — 2019-01-22
- 1.0.2 — 2019-01-22
- 1.0.1 — 2019-01-21
- 1.0.0 — 2019-01-21

## README

# Langparse 使用说明

## 安装

```bash
npm install --save-dev langparse
```

## 设置命令

在项目 package.json 的 script 中增加如下命令
```json
"lang": "node ./node_modules/langparse/index.js"
```

## 初始化

### 公共配置初始化
```bash
npm run lang init
```

会在项目最外层生成如下文件

```js
|-- langConfig
        |-- baseConfig.js // 有关项目的基础设置
        |-- defaultConfig.js // 编译文本的初始设置
        |-- README.md // 使用说明
```

### 快速使用

```
// init 之后可执行
npm run lang
```

### 子项目 [projectName] 初始化

```bash
npm run lang init [projectName]
```

会在 baseConfig.js 配置好的子项目位置中创建

```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`
字段|默认值|功能
-|-|-
langNameKey|`en_US`| 与 lang 对应，英文的名称
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<br/>例1：`"true" => this {0} still need to slash {1} more to get this product` <br/>例2：`"false" => this xx still need to slash ฿xx.xx more to get this product`
currencySymbol|`空`| 是否需要替换货币符，`insertReserved = true` 时此设置才生效<br/>例1：`"￥$฿" => this {0} still need to slash {1} more to get this product` <br/>例2：`"" => this {0} still need to slash ฿{1} more to get this product`
keyStyle|`space`| 命名风格 `3 => this_StillNeed...`<br/>例1：`"Camel" => this_StillNeedToSlash_More...`<br/>例2：`"Pascal" => This_StillNeedToSlash_More...`<br/>例3：`"space" => this _ still need to slash _ more...`
preStr|`空`| 命名前缀 `"[str]" => [str]this_StillNeedToSlash_More...`

注： `langConfig.js` 未配置的部分，会采用 `defaultConfig.js` 中的值。`defaultConfig.js` 必须配置每一项

---
_Source: https://npm.io/package/langparse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
