Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork25
🌐 vue-i18n loader for custom blocks
License
intlify/vue-i18n-loader
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
webpack loader for Vue I18n
This package is maintained for Vue I18n v8 (Vue 2).
If you want to use Vue I18n v9 (Vue 3) or later, See the@intlify/bundle-tools repo.
$ npm i --save-dev @intlify/vue-i18n-loaderthe below example thatApp.vue havei18n custom block:
<template> <p>{{ $t('hello') }}</p></template><script>exportdefault { name:'app',// ...}</script><i18n>{ "en": { "hello": "hello world!" }, "ja": { "hello": "こんにちは、世界!" }}</i18n>
The locale messages defined ati18n custom blocks arejson format default.
you also can:
<i18n src="./myLang.json"></i18n>
// ./myLnag.json{"en":{"hello":"hello world!"},"ja":{"hello":"こんにちは、世界!"}}
You can define locale messages for each locale withlocale attr in single-file components:
<i18n locale="en">{ "hello": "hello world!"}</i18n><i18n locale="ja">{ "hello": "こんにちは、世界!"}</i18n>
The above defines two locales, which are merged at target single-file components.
Besides json format, You can be used by specifying the following format in thelang attribute:
- yaml
- json5
example yaml foramt:
<i18n locale="en" lang="yaml">hello:"hello world!"</i18n><i18n locale="ja" lang="yml"> hello: "こんにちは、世界!"</i18n>
example json5 format:
<i18n lang="json5">{ "en": { // comments "hello": "hello world!" }}</i18n>
importVuefrom'vue'importVueI18nfrom'vue-i18n'importAppfrom'./App.vue'Vue.use(VueI18n)consti18n=newVueI18n({locale:'en',messages:{en:{// ...},ja:{// ...}}})newVue({ i18n,render:h=>h(App)}).$mount('#app')
vue-loader (v15 or later):
// for vue.config.js (Vue CLI)module.exports={chainWebpack:config=>{config.module.rule('i18n').resourceQuery(/blockType=i18n/).type('javascript/auto').use('i18n').loader('@intlify/vue-i18n-loader')}}
vue-loader (v15 or later):
// for webpack.config.js (Without Vue CLI)module.exports={module:{rules:[{resourceQuery:/blockType=i18n/,type:'javascript/auto',loader:'@intlify/vue-i18n-loader',},]}}
vue-loader (~v14.x):
// for webpack config filemodule.exports={module:{rules:[{test:/\.vue$/,loader:'vue',options:{loaders:{i18n:'@intlify/vue-i18n-loader'}}}]}}
Details changes for each release are documented in theCHANGELOG.md.
Please make sure to read theContributing Guide before making a pull request.
About
🌐 vue-i18n loader for custom blocks
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors13
Uh oh!
There was an error while loading.Please reload this page.
