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
Requirements
- works with Vue.js ^
0.12.0
Instllation
npm
$ npm install vue-i18n
bower
$ bower install vue-i18n
duo
var i18n = require('kazupon/vue-i18n')
Usage
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
})
// create instance
new Vue({
el: '#test-i18n'
})
Template the following:
<div id="test-i18n" class="message">
<p>{{ $t("message.hello") }}</p>
</div>
Output the following:
<div id="test-i18n" class="message">
<p>ザ・ワールド</p>
</div>
Formatting
Named formatting
Locale the following:
var locales = {
en: {
message: {
hello: '{msg} world'
}
}
}
Template the following:
<div class="message">
<p>{{ $t('message.hello', { msg: "hello"}) }}</p>
</div>
Output the following:
<div class="message">
<p>hello world</p>
</div>
List formatting
Locale the following:
var locales = {
en: {
message: {
hello: '{0} world'
}
}
}
Template the following:
<div class="message">
<p>{{ $t('message.hello', ["hello"]) }}</p>
</div>
Output the following:
<div class="message">
<p>hello world</p>
</div>
API
#$t(keypath, [lang], [arguments])
- keypath:
String
required - lang:
String
optional - arguments:
Array | Object
optional
Translate the locale of keypath
. if specify lang
, translate the locale of lang
. if you are specified list formatting locale or named formatting of keypath
, also you must specify arguments
.
Contributing
- Fork it !
- Create your top branch from
dev
:git branch my-new-topic origin/dev
- Commit your changes:
git commit -am 'Add some topic'
- Push to the branch:
git push origin my-new-topic
- Submit a pull request to
dev
branch ofvuejs/vue-validator
repository !
Testing
$ make test