vue-wording

1.0.3 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i vue-wording

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

35.5 kB

Total Files

28

Last publish

Collaborators

  • benavern