Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit aa93810

Browse files
committed
update docs
1 parent 6a64417 commit aa93810

File tree

1 file changed

+76
-27
lines changed

1 file changed

+76
-27
lines changed

README.md

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ You need to install the follwoing:
1919
If you use rollup-plugin-vue, We recommend you should read the [docs](https://rollup-plugin-vue.vuejs.org/)
2020

2121

22+
## :star: Features
23+
- i18n resources pre-compilation
24+
- i18n custom block
25+
26+
2227
## :cd: Installation
2328

2429
### NPM
@@ -78,7 +83,7 @@ export default [
7883

7984
#### Notes on using with other i18n resource loading plugins
8085

81-
If you use the plugin like `@rollup/plugin-json`, make sure that the i18n resource to be precompiled with `rollup-plugin-vue-i18n` is not loaded. you need to filter with the plugin options.
86+
If you use the plugin like `@rollup/plugin-json`, make sure that the i18n resource to be pre-compiled with `rollup-plugin-vue-i18n` is not loaded. you need to filter with the plugin options.
8287

8388

8489
### `i18n` custom block
@@ -151,37 +156,81 @@ ja:
151156
</i18n>
152157
```
153158

154-
### `forceStringify` options
159+
## :wrench: Options
155160

156-
Whether pre-compile number and boolean values as message functions that return the string value, default `false`
161+
### `include`
157162

158-
```ts
159-
import VuePlugin from 'rollup-plugin-vue'
160-
import VueI18nPlugin from 'rollup-plugin-vue-i18n'
161-
import resolve from '@rollup/plugin-node-resolve'
162-
import commonjs from '@rollup/plugin-commonjs'
163-
import path from 'path'
163+
- **Type:** `string | string[] | undefined`
164+
- **Default:** `undefined`
164165

165-
export default [
166+
A [minimatch](https://github.com/isaacs/minimatch) pattern, or array of patterns, you can specify a path to pre-compile i18n resources files. The extensions of i18n resources to be precompiled are as follows:
167+
168+
```
169+
- json
170+
- json5
171+
- yaml
172+
- yml
173+
```
174+
175+
176+
### `forceStringify`
177+
178+
- **Type:** `boolean`
179+
- **Default:** `false`
180+
181+
Whether pre-compile number and boolean values as message functions that return the string value.
182+
183+
for example, the following json resources:
184+
185+
```json
166186
{
167-
input: path.resolve(__dirname, `./src/main.js`),
168-
output: {
169-
file: path.resolve(__dirname, `./dist/index.js`),
170-
format: 'cjs'
171-
},
172-
plugins: [
173-
VuePlugin({ customBlocks: ['i18n'] }),
174-
VueI18nPlugin({
175-
include: path.resolve(__dirname, `./path/to/src/locales/**`)
176-
// `forceStringify` option
177-
forceStringify: true
178-
}),
179-
resolve(),
180-
commonjs()
181-
]
187+
"trueValue": true,
188+
"falseValue": false,
189+
"nullValue": null,
190+
"numberValue": 1
182191
}
183-
]
184-
```
192+
```
193+
194+
after pre-compiled (development):
195+
196+
```js
197+
export default {
198+
"trueValue": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["true"])};fn.source="true";return fn;})(),
199+
"falseValue": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["false"])};fn.source="false";return fn;})(),
200+
"nullValue": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["null"])};fn.source="null";return fn;})(),
201+
"numberValue": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["1"])};fn.source="1";return fn;})()
202+
}
203+
```
204+
205+
Configration example:
206+
207+
```ts
208+
import VuePlugin from 'rollup-plugin-vue'
209+
import VueI18nPlugin from 'rollup-plugin-vue-i18n'
210+
import resolve from '@rollup/plugin-node-resolve'
211+
import commonjs from '@rollup/plugin-commonjs'
212+
import path from 'path'
213+
214+
export default [
215+
{
216+
input: path.resolve(__dirname, `./src/main.js`),
217+
output: {
218+
file: path.resolve(__dirname, `./dist/index.js`),
219+
format: 'cjs'
220+
},
221+
plugins: [
222+
VuePlugin({ customBlocks: ['i18n'] }),
223+
VueI18nPlugin({
224+
include: path.resolve(__dirname, `./path/to/src/locales/**`)
225+
// `forceStringify` option
226+
forceStringify: true
227+
}),
228+
resolve(),
229+
commonjs()
230+
]
231+
}
232+
]
233+
```
185234

186235
## :scroll: Changelog
187236
Details changes for each release are documented in the [CHANGELOG.md](https://github.com/intlify/rollup-plugin-vue-i18n/blob/master/CHANGELOG.md).

0 commit comments

Comments
 (0)