Natively Pronounced Mandarin
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

@kazupon/vue-i18n-loader

0.3.0 • Public • Published

🌐 vue-i18n-loader

CircleCI codecov npm

vue-i18n loader for custom blocks

💿 Installation

$ npm i --save-dev @kazupon/vue-i18n-loader

🚀 Usage

the below example thatApp.vue have i18n custom block:

Custom Blocks (Single File Components)

<i18n>
{
  "en": {
    "hello": "hello world!"
  },
  "ja": {
    "hello": "こんにちは、世界!"
  }
}
</i18n>
 
<template>
  <p>{{ $t('hello') }}</p>
</template>
 
<script>
export default {
  name: 'app',
  // ...
}
</script> 

JavaScript

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './App.vue'
 
Vue.use(VueI18n)
 
const i18n = new VueI18n({
  locale: 'en',
  messages: {
    en: {
      // ...
    },
    ja: {
      // ...
    }
  }
})
new Vue({
  i18n,
  render: h => h(App)
}).$mount('#app')

Webpack Config

configure webpack config for vue-loader (v11.3 later):

module.exports = {
  module: {
    rules: [{
      test: /\.vue$/,
      loader: 'vue',
      options: {
        loaders: {
          i18n: '@kazupon/vue-i18n-loader'
        }
      }
    }]
  }
}

📜 Changelog

Details changes for each release are documented in the CHANGELOG.md.

💪 Contribution

Please make sure to read the Contributing Guide before making a pull request.

©️ License

MIT

install

npm i @kazupon/vue-i18n-loader

Downloadsweekly downloads

21,447

version

0.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability