This plugin is based on https://github.com/rmariuzzo/Lang.js
This Vue plugin can be installed via npm or yarn
$ npm install @eli5/vue-lang-js
$ yarn add @eli5/vue-lang-js
Start by importing the component.
import Vue from 'vue'
import VueLang from '@eli5/vue-lang-js'
Vue.use(VueLang, {
messages: source, // Provide locale file
locale: 'nl', // Set locale
fallback: 'en' // Set fallback lacale
})
Get language string
this.$trans('auth.title')
this.$trans('auth.title', { name: 'eli5' })
{{ $trans('auth.title') }}
{{ $trans('auth.title', { name: 'eli5' }) }}
// Alias
this.$t('auth.title')
this.$t('auth.title', { name: 'eli5' })
{{ $t('auth.title') }}
{{ $t('auth.title', { name: 'eli5' }) }}
Get language string with plural
this.$choice('auth.title', int)
this.$choice('auth.title', int, { name: 'eli5' })
{{ $choice('auth.title', int) }}
{{ $choice('auth.title', int, { name: 'eli5' }) }}
// Alias
this.$tc('auth.title', int)
this.$tc('auth.title', int, { name: 'eli5' })
{{ $tc('auth.title', int) }}
{{ $tc('auth.title', int, { name: 'eli5' }) }}
Set locale
this.$lang.setLocale('en')