Vue wording plugin
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
config
lib
src
static
.babelrc
.editorconfig
.eslintignore
.eslintrc.js
.gitignore
.postcssrc.js
README.md
index.html
package-lock.json
package.json

README.md

vue-wording

npm version

Simple wording plugin for Vue.js

How To

install dependency

npm i -S vue-wording

create a json file with your wording (root node must be the lang)

{
  "fr": {
    "simple": "Hello, World!",
    "complicated": "j'ai mangé #{nb} #{things} et c'était #{nb} fois plus #{feeling}!",
    "anotherWording": "Ce wording a été compilé avec amour! #{notrad}",
    "plainObject": {
      "key": "value: #{val}",
      "array": [1, 2, {"third": "#{three}" }]
      }
    }
  }

install the plugin in your app.js

import Vue from 'vue'

import wordingPlugin from 'vue-wording'
import wording from './wording.json'

Vue.use(wordingPlugin, {lang: 'fr', wording})

new Vue({
  // ...
})

Use the plugin in your vue components

<template>
  <div>
    {{ $t('complicated', {nb: 3, things: 'bananas', feeling: 'cool'}) }}
  </div>
</template>
<script>
  export default {
    data () {
      return {
        simple: this.$t('simple')
      }
    }
  }
</script>