Gathering detailed insights and metrics for @intlify/vite-plugin-vue-i18n
Gathering detailed insights and metrics for @intlify/vite-plugin-vue-i18n
Gathering detailed insights and metrics for @intlify/vite-plugin-vue-i18n
Gathering detailed insights and metrics for @intlify/vite-plugin-vue-i18n
@intlify/unplugin-vue-i18n
unplugin for Vue I18n
@yfwz100/vite-plugin-vue2-i18n
The missing vue 2 SFC version of vite plugin for vue-i18n, inspired by [the rollup one](https://github.com/intlify/rollup-plugin-vue-i18n/tree/master).
@intlify-lry/unplugin-vue-i18n
unplugin for Vue I18n
@padcom/vite-plugin-vue-i18n-kudutsa
A pass-through (kudutsa in chewa) to @intlify/unplugin-vue-i18n plugin
bundling for intlify i18n tools
npm install @intlify/vite-plugin-vue-i18n
Typescript
Module System
Min. Node Version
Node Version
NPM Version
@intlify/unplugin-vue-i18n@6.0.8
Updated on Apr 21, 2025
@intlify/unplugin-vue-i18n@6.0.7
Updated on Apr 21, 2025
@intlify/unplugin-vue-i18n@6.0.5
Updated on Apr 20, 2025
v12.0.0-alpha.2
Updated on Apr 20, 2025
v12.0.0-alpha.1
Updated on Mar 20, 2025
v12.0.0-alpha.0
Updated on Mar 20, 2025
TypeScript (75.88%)
JavaScript (19.62%)
Vue (3.37%)
HTML (0.89%)
Shell (0.24%)
Total Downloads
7,178,739
Last Day
4,158
Last Week
25,745
Last Month
101,350
Last Year
1,453,318
MIT License
257 Stars
482 Commits
41 Forks
8 Watchers
23 Branches
31 Contributors
Updated on May 10, 2025
Minified
Minified + Gzipped
Latest Version
7.0.0
Package Id
@intlify/vite-plugin-vue-i18n@7.0.0
Unpacked Size
40.76 kB
Size
8.96 kB
File Count
7
NPM Version
8.5.5
Node Version
16.11.0
Cumulative downloads
Total Downloads
Last Day
49%
4,158
Compared to previous day
Last Week
13.6%
25,745
Compared to previous week
Last Month
-17.7%
101,350
Compared to previous month
Last Year
-32.4%
1,453,318
Compared to previous year
3
1
Vite plugin for Vue I18n
1$ npm i --save-dev @intlify/vite-plugin-vue-i18n
1$ yarn add -D @intlify/vite-plugin-vue-i18n
When this plugin is installed, Vue I18n can only use the Composition API, and if you want to use the Legacy API, you need to set the compositionOnly
option to false
.
Also, if you do a production build with vite, Vue I18n will automatically bundle the runtime only module. If you need on-demand compilation with Message compiler, you need to set the runtimeOnly
option to false
.
Since vue-i18n@v9.x
, the locale messages are handled with message compiler, which converts them to javascript functions after compiling. After compiling, message compiler converts them into javascript functions, which can improve the performance of the application.
However, with the message compiler, the javascript function conversion will not work in some environments (e.g. CSP). For this reason, vue-i18n@v9.x
and later offer a full version that includes compiler and runtime, and a runtime only version.
If you are using the runtime version, you will need to compile before importing locale messages by managing them in a file such as .json
.
1import { defineConfig } from 'vite'
2import { resolve, dirname } from 'node:path'
3import { fileURLToPath } from 'url'
4import vue from '@vitejs/plugin-vue'
5import vueI18n from '@intlify/vite-plugin-vue-i18n'
6
7export default defineConfig({
8 plugins: [
9 vue(), // you need to install `@vitejs/plugin-vue`
10 vueI18n({
11 // if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
12 // compositionOnly: false,
13
14 // you need to set i18n resource including paths !
15 include: resolve(dirname(fileURLToPath(import.meta.url)), './path/to/src/locales/**'),
16 })
17 ]
18})
The below example that examples/composition/App.vue
have i18n
custom block:
1<template> 2 <form> 3 <label>{{ t('language') }}</label> 4 <select v-model="locale"> 5 <option value="en">en</option> 6 <option value="ja">ja</option> 7 </select> 8 </form> 9 <p>{{ t('hello') }}</p> 10</template> 11 12<script> 13import { useI18n } from 'vue-i18n' 14 15export default { 16 name: 'App', 17 setup() { 18 const { locale, t } = useI18n({ 19 inheritLocale: true 20 }) 21 22 return { locale, t } 23 } 24} 25</script> 26 27<i18n> 28{ 29 "en": { 30 "language": "Language", 31 "hello": "hello, world!" 32 }, 33 "ja": { 34 "language": "言語", 35 "hello": "こんにちは、世界!" 36 } 37} 38</i18n>
You can be used by specifying the following format in the lang
attribute:
example yaml
format:
1<i18n lang="yaml"> 2en: 3 hello: 'Hello World!' 4ja: 5 hello: 'こんにちは、世界!' 6</i18n>
vite-plugin-vue-i18n allows you to statically bundle i18n resources such as json
or yaml
specified by the include
option of the plugin described below as locale messages with the import
syntax.
In this case, only one i18n resource can be statically bundled at a time with import
syntax, so the these code will be redundant for multiple locales.
1import { createApp } from 'vue' 2import { createI18n } from 'vue-i18n' 3/* 4 * The i18n resources in the path specified in the plugin `include` option can be read 5 * as vue-i18n optimized locale messages using the import syntax 6 */ 7import en from './src/locales/en.json' 8import ja from './src/locales/ja.yaml' 9import fr from './src/locales/fr.json5' 10 11const i18n = createI18n({ 12 locale: 'en', 13 messages: { 14 en, 15 ja, 16 fr 17 } 18}) 19 20const app = createApp() 21app.use(i18n).mount('#app')
vite-plugin-vue-i18n can use the vite (rollup) mechanism to import all locales at once, using the special identifier @intlify/vite-plugin-vue-i18n/messages
, as the bellow:
1import { createApp } from 'vue' 2import { createI18n } from 'vue-i18n' 3/* 4 * All i18n resources specified in the plugin `include` option can be loaded 5 * at once using the import syntax 6 */ 7import messages from '@intlify/vite-plugin-vue-i18n/messages' 8 9const i18n = createI18n({ 10 locale: 'en', 11 messages 12}) 13 14const app = createApp() 15app.use(i18n).mount('#app')
If you want type definition of @intlify/vite-plugin-vue-i18n/messages
, add vite-plugin-vue-i18n/client
to compilerOptions.types
of your tsconfig:
1{ 2 "compilerOptions": { 3 "types": ["@intlify/vite-plugin-vue-i18n/client"] 4 } 5}
vite-plugin-vue-i18n allows you to support bundle size optimization provided by vue-i18n.
petite-vue-i18n
(Experimental)vite-plugin-vue-i18n plugin support for petite-vue-i18n
.
vite-plugin-vue-i18n plugin provides several dedicated options for petite-vue-i18n
.
Note that it is as experimental as Petite-vue-i18n
.
As noted here, NPM provides many different builds of Vue I18n.
vite-plugin-vue-i18n will automatically select and bundle Vue I18n build according to the following vite behavior:
vue-i18n.esm-bundler.js
vue-i18n.runtime.esm-bundler.js
About details, See the here
petite-vue-i18n
vite-plugin-vue-i18n will automatically select and bundle petite-vue-i18n
build according to the following vite behavior:
petite-vue-i18n.esm-bundler.js
petite-vue-i18n.runtime.esm-bundler.js
You can specify options in the plugin option to support bundle size optimization provided by vue-i18n.
The same thing can be configured with the define
option, but the plugin option is more friendly. Especially if you are using typescript, you can use intelisense.
About details, See the below section
include
Type: string | string[] | undefined
Default: undefined
A 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:
- json
- json5
- yaml
- yml
Note json
resources matches this option, it will be handled before the internal json plugin of Vite, and will not be processed afterwards, else the option doesn't match, the Vite side will handle.
runtimeOnly
Type: boolean
Default: true
Whether or not to automatically use Vue I18n runtime-only in production build, set in the vue-i18n
field of Vite resolve.alias
option.
If false
is specified, Vue I18n (vue-i18n) package.json module
field will be used.
For more details, See here
compositionOnly
Type: boolean
Default: true
Whether to make vue-i18n's API only composition API. By default the legacy API is tree-shaken.
For more details, See here
fullInstall
Type: boolean
Default: true
Whether to install the full set of APIs, components, etc. provided by Vue I18n. By default, all of them will be installed.
If false
is specified, buld-in components and directive will not be installed in vue and will be tree-shaken.
For more details, See here
forceStringify
Type: boolean
Default: false
Whether pre-compile number and boolean values as message functions that return the string value.
For example, the following json resources:
1{ 2 "trueValue": true, 3 "falseValue": false, 4 "nullValue": null, 5 "numberValue": 1 6}
after pre-compiled (development):
1export default { 2 trueValue: (() => { 3 const fn = ctx => { 4 const { normalize: _normalize } = ctx 5 return _normalize(['true']) 6 } 7 fn.source = 'true' 8 return fn 9 })(), 10 falseValue: (() => { 11 const fn = ctx => { 12 const { normalize: _normalize } = ctx 13 return _normalize(['false']) 14 } 15 fn.source = 'false' 16 return fn 17 })(), 18 nullValue: (() => { 19 const fn = ctx => { 20 const { normalize: _normalize } = ctx 21 return _normalize(['null']) 22 } 23 fn.source = 'null' 24 return fn 25 })(), 26 numberValue: (() => { 27 const fn = ctx => { 28 const { normalize: _normalize } = ctx 29 return _normalize(['1']) 30 } 31 fn.source = '1' 32 return fn 33 })() 34}
defaultSFCLang
Type: string
Default: undefined
Specify the content for all your inlined i18n
custom blocks on your SFC
.
defaultSFCLang
must have one of the following values:
- json
- json5
- yaml
- yml
On inlined i18n
custom blocks that have specified the lang
attribute, the defaultSFCLang
is not applied.
For example, with defaultSFCLang: "yaml"
or defaultSFCLang: "yml"
, this custom block:
1<i18n lang="yaml"> 2en: 3 hello: Hello 4es: 5 hello: Hola 6</i18n>
and this another one, are equivalent:
1<i18n> 2en: 3 hello: Hello 4es: 5 hello: Hola 6</i18n>
globalSFCScope
Type: boolean
Default: undefined
Whether to include all i18n
custom blocks on your SFC
on global
scope.
If true
, it will be applied to all inlined i18n
or imported
custom blocks.
Warning: beware enabling globalSFCScope: true
, all i18n
custom blocks in all your SFC
will be on global
scope.
For example, with globalSFCScope: true
, this custom block:
1<i18n lang="yaml" global> 2en: 3 hello: Hello 4es: 5 hello: Hola 6</i18n>
and this another one, are equivalent:
1<i18n lang="yaml"> 2en: 3 hello: Hello 4es: 5 hello: Hola 6</i18n>
You can also use defaultSFCLang: "yaml"
, following with previous example, this another is also equivalent to previous ones:
1<i18n> 2en: 3 hello: Hello 4es: 5 hello: Hola 6</i18n>
useVueI18nImportName
(Experimental)Type: boolean
Default: false
Whether to use the import name of petite-vue-i18n
with the same import name as vue-i18n (import { xxx } from 'vue-i18n'
).
This option allows a smooth migration from petite-vue-i18n
to vue-i18n
and allows progressive enhacement.
Details changes for each release are documented in the CHANGELOG.md
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
21 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More