# vue3-i18n-extractor

> vue3-i18n-extractor

Latest version **0.0.5** (published 2023-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue3-i18n-extractor
pnpm add vue3-i18n-extractor
yarn add vue3-i18n-extractor
bun add vue3-i18n-extractor
```

Provides the command `extract`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-11-17 |
| First published | 2023-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 14 |
| Unpacked size | 77.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zyx |
| Maintainers | burning_star |

## Links

- npm: https://www.npmjs.com/package/vue3-i18n-extractor
- npm.io page: https://npm.io/package/vue3-i18n-extractor

## Dependencies (14)

- [glob](https://npm.io/package/glob.md) ^10.3.10
- [eslint](https://npm.io/package/eslint.md) ^8.48.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.0
- [prettier](https://npm.io/package/prettier.md) ^2.0.0
- [commander](https://npm.io/package/commander.md) ^8.3.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.22.11
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.16.0
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.16.4
- [@babel/template](https://npm.io/package/@babel/template.md) ^7.22.5
- [@babel/traverse](https://npm.io/package/@babel/traverse.md) ^7.16.3
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.22.10
- [@vue/compiler-sfc](https://npm.io/package/@vue/compiler-sfc.md) ^3.2.22
- [@vue/compiler-core](https://npm.io/package/@vue/compiler-core.md) ^3.2.47
- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.22.5

## Recent versions

- 0.0.5 (latest) — 2023-11-17
- 0.0.4 — 2023-11-17
- 0.0.3 — 2023-11-17
- 0.0.2 — 2023-11-17
- 1.0.1 — 2023-11-16

## README

### vue3-i18n-extractor

基于 babel 和@vue/compiler-sfc，将当前工作目录（cwd）内的汉语字符串提取为 JSON 到指定输出目录，同时将原有内容替换为 i18n 的占位符（如$t()或 i8n.global.t()），以实现自动国际化。

### 安装

```
$ npm i vue3-i18n-extractor -g
```

### 使用方法

cli命令

```
$ extract
```

### 选项

| 选项                           |                                                                          |
| ------------------------------ | ------------------------------------------------------------------------ |
| --importPath <path>            | i18n 的导出路径                                                          |
| --importName <name>            | i18n 的导出变量名                                                        |
| --outputPath <outputPath>      | 提取的 JSON 文件导出路径                                                 |
| --outputFileName <outputname> | 提取的 JSON 文件名,默认值为 zh-CN.json                                   |
| --pattern <pattern>           | 文件匹配模式，遵循 glob 语法，默认值为'\*_/_.{vue.js}                  |
| --ignore <ignore>             | 忽略文件，遵循 glob 语法，也可以是一个数组,默认值为'['node_modules/**'] |

可以使用 cli 命令指定，也可以在 package.json 中指定 i18nExtractOptions 指定选项参数,最终会与 cli 选项合并

```
type i18nExtractOptions ={
  pattern: string[]｜string;
  ignore: string[]|string;
  importPath?: string;
  importName?: string;
  outputPath?: string;
  outputFileName: string;
};

```

### 已知问题

受限于babel，vue模版语法中，绑定对象时，不可以有尾逗号

```
<!-- x -->
:style={color: 'red',}
<!-- ✔ -->
:style={color: 'red'}
```

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