Package Exports
- vue-i18n
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-i18n) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vue-i18n
Internationalization plugin of Vue.js
Requirments
- works with Vue.js ^
0.10.4
Instllation
component
$ component install kazupon/vue-i18n
bower
$ bower install vue-i18n
browserify
$ npm install vue-i18n
Usage
v-t directive
var Vue = require('vue')
var i18n = require('vue-i18n')
// ready translated locales
var locales = {
en: {
message: {
hello: 'the world'
}
},
ja: {
message: {
hello: 'ザ・ワールド'
}
}
}
// set plugin
Vue.use(i18n, {
lang: 'ja',
locales: locales // NOTE: 'resources' is deprecated
})
// create instance
new Vue({
el: '#test-i18n'
})
Template the following:
<div id="test-i18n" class="message">
<p v-t="message.hello"></p>
</div>
Output the following:
<div id="test-i18n" class="message">
<p>ザ・ワールド</p>
</div>
Vue.t function
var Vue = require('vue')
var i18n = require('vue-i18n')
// ready translated locales
var locales = {
en: {
message: {
hello: 'the world'
}
},
ja: {
message: {
hello: 'ザ・ワールド'
}
}
}
// set plugin
Vue.use(i18n, {
lang: 'en',
locales: locales
})
console.log(Vue.t('message.hello')) // output the 'the wolrd'
$t method (for 0.11.4 later)
<div id="message">
Message:<br>{{$t('message.hello')}}
</div>
var Vue = require('vue')
var i18n = require('vue-i18n')
// ready translated locales
var locales = {
en: {
message: {
hello: 'the world'
}
},
ja: {
message: {
hello: 'ザ・ワールド'
}
}
}
// set plugin
Vue.use(i18n, {
lang: 'en',
locales: locales
})
new Vue().$mount('#message')
render the following:
<div id="message">
Message:<br>the world
</div>
Testing
$ make test
TODO
See the TODO.md
License
MIT
See the LICENSE
.