You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/advanced/optimization.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,11 +23,11 @@ Also, the message compiler is not bundled, therefore **bundle size can be reduce
23
23
We can configure these modules with module path using the module resolve alias feature (e.g. `resolve.alias` vite and webpack) of some bundler, but It takes time and effort.
24
24
Intlify project provides plugins/loaders for some bundlers, for simplicity
25
25
26
-
### `@intlify/unplugin-vue-i18n`
26
+
### unplugin-vue-i18n
27
27
28
28
[`unplugin`](https://github.com/unjs/unplugin) is an unified plugin system for bundle tool such as vite, webpack, rollup, esbuild and etc.
29
29
30
-
Intlify project is providing [`@intlify/unplugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n) for vite and webpack.
30
+
Intlify project is providing [`unplugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n) for vite and webpack.
31
31
32
32
If you do the production build, Vue I18n will automatically bundle the runtime only module
33
33
@@ -83,11 +83,11 @@ module.exports = {
83
83
84
84
About optoins and features, see the detail [page](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n#intlifyunplugin-vue-i18n)
85
85
86
-
### `@intlify/vite-plugin-vue-i18n`
86
+
### vite-plugin-vue-i18n
87
87
88
88
[`vite`](https://vitejs.dev/) is next generation frontend tooling.
89
89
90
-
Intlify project is providing [`@intlify/vite-plugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n)
90
+
Intlify project is providing [`vite-plugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n)
91
91
92
92
If you do a production build, Vue I18n will automatically bundle the runtime only module
[vite-plugin-vue-i18n](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n) is vite plugin for [Vite](https://github.com/vitejs/vite).
@@ -60,6 +124,10 @@ To use i18n custom blocks, you need to use the following plugins for bundler.
60
124
- @vitejs/plugin-vue: **v1.0.4 or later**.
61
125
:::
62
126
127
+
:::warning NOTICE
128
+
This plugin will be deprecated in the near future, because we can replace `unplugin-vue-i18n`.
This plugin will be deprecated in the near future, because we can replace `unplugin-vue-i18n`.
175
+
:::
176
+
105
177
#### Installation
106
178
107
179
```sh
@@ -158,6 +230,10 @@ module.exports = {
158
230
- rollup-plugin-vue: **v6 or later**.
159
231
:::
160
232
233
+
:::warning NOTICE
234
+
This plugin will be deprecated in the near future, because we can replace `unplugin-vue-i18n`.
235
+
:::
236
+
161
237
#### Installation
162
238
163
239
```sh
@@ -303,7 +379,7 @@ The `i18n` custom blocks below of `json5` format:
303
379
304
380
### Define global format
305
381
306
-
If you are using one of `@intlify/vite-plugin-vue-i18n` plugin on your project, you can also define the `lang` for all your inlined `i18n` custom blocks on all your SFC using the `defaultSFCLang` option.
382
+
If you are using `unplugin-vue-i18n` and `vite-plugin-vue-i18n` on your project, you can also define the `lang` for all your inlined `i18n` custom blocks on all your SFC using the `defaultSFCLang` option.
307
383
308
384
:::warning NOTICE
309
385
`@intlify/vue-i18n-loader` and `@intlify/rollup-plugin-vue-i18n` are currently in progress to add this feature.
@@ -392,6 +468,20 @@ plugins: [
392
468
You can use define locale messages for global scope with `global` attribute:
393
469
394
470
```html
471
+
<script setup lang="ts">
472
+
import { useI18n } from'vue-i18n'
473
+
// something imports ...
474
+
475
+
/**
476
+
* NOTE:
477
+
* you **must always call `useI18n` in global scope.
478
+
* If you do not call it, the resource defined in the custom block will not be enabled.
479
+
*/
480
+
const { t } =useI18n(/*{ useScope: 'global' }*/)
481
+
482
+
// something todo ...
483
+
</script>
484
+
395
485
<i18n global>
396
486
{
397
487
"en": {
@@ -403,9 +493,14 @@ You can use define locale messages for global scope with `global` attribute:
403
493
404
494
In the above example, since the `global` attribute is set, the locale messages defined in `i18n` custom blocks can be merged as a resource for locale messages of global scope.
405
495
496
+
:::warning NOTICE
497
+
you **must always call `useI18n` in global scope.
498
+
If you do not call it, the resource defined in the custom block will not be enabled.
499
+
:::
500
+
406
501
### Define global scope
407
502
408
-
If you are using one of `@intlify/vite-plugin-vue-i18n` plugin on your project, you can also define the `global` scope for all your `i18n` custom blocks on all your SFC using the `globalSFCScope` option.
503
+
If you are using `unplugin-vue-i18n` and `vite-plugin-vue-i18n` on your project, you can also define the `global` scope for all your `i18n` custom blocks on all your SFC using the `globalSFCScope` option.
409
504
410
505
:::warning NOTICE
411
506
`@intlify/vue-i18n-loader` and `@intlify/rollup-plugin-vue-i18n` are currently in progress to add this feature.
0 commit comments