vue-simple-translate
v1.0.1
Published
Serve json_encoded translation-arrays from html to vue.
Downloads
3
Readme
vue-simple-translate
Serve json_encoded translation-arrays from html to vue.
Installation
Install package
npm install vue-simple-translate --save
Setup
import VueSimpleTranslate from 'vue-simple-translate'
Vue.use(VueSimpleTranslate)
Usage
Add translations from HTML
Simple JSON
<div v-translate="{foo: 'bar'}">...</div>
With multidimensional JSON
<div v-translate="{foo: 'bar', user: {name: 'FOO', email: '[email protected]'}}">...</div>
Namespace your translations
To namespace the translations, you can simply add the namepsace as directive-argument
<div v-translate:awesome="{foo: 'bar'}">...</div>
Getting translations
To access the translations you can simply use the $trans-method.
this.$trans('foo')
this.$trans('user.name')
Or in HTML
<div>
{{ this.$trans('foo') }}
</div>
Use with laravel
To integrate the translation-files from laravel simply use the laravel trans-helper and add it json_encoded
<div v-translate:users="{{ json_encode(trans('users')) }}">