vue-i18n-filter icon indicating copy to clipboard operation
vue-i18n-filter copied to clipboard

๐ŸŒ { 'vue-i18n' | t }

Vue-I18n-filter ยท GitHub license npm version npm downloads PRs Welcome

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 }}