vue-i18n-filter
vue-i18n-filter copied to clipboard
๐ { 'vue-i18n' | t }
Vue-I18n-filter ยท

Vue-I18n-filter is a Vue filter
mix-in for Vue-I18n, which allow you use Vue filter to declare Vue-i18n.
Installation
npm install vue-i18n-filter
import VueI18n from 'vue-i18n'
import VueI18nFilter from 'vue-i18n-filter'
Vue.use(VueI18n)
Vue.use(VueI18nFilter)
Usage
Vue filters t
, te
, tc
will mixed-in,
equal effect with $t
, $te
, $tc
of vue-i18n
.
avoid to declare Vue filter name as t
, te
or tc
in component when using Vue-i18n-filter.
Basic usage
{{ 'ไฝ ๅฅฝ' | t }} // hello
Example
var message = {
ja: {
message: {
hello: 'ใใใซใกใฏใไธ็',
greeting: 'ใใ๏ผ',
greeting2: 'ใใ {name}๏ผ',
apple: 'ๆๆชใฃใฆใใพใฃใ | one ๆๆช | {count}ใฎๆๆช'
}
}
}
{{ 'message.hello' | t }} // ใใใซใกใฏใไธ็
{{ 'message.greeting2' | t({ name: 'kazupon' }) }} // ใใ kazupon๏ผ
{{ 'message.hello' | te('en') }} // true
{{ 'message.apple' | tc(0) }} // ๆๆชใฃใฆใใพใฃใ
{{ 'message.apple' | tc(10, { count: 10 }) }} // 10ใฎๆๆช
filters chain example
translate and capitalize
{{ 'message.hello' | t | capitalize }}