@eli5/vue-lang-js
Use lang.js inside Vue.js
8,753
5
| Install | |
|---|---|
npm install @eli5/vue-lang-js |
|
| Latest Version: | 1.3.1 |
| Vue: | 2 |
| License: | MIT |
| Last Updated: | Dec 8, 2022 |
| Links: | GitHub · npm |
Maintainer: eli5_amsterdam
lang-js-vue
This plugin is based on https://github.com/rmariuzzo/Lang.js
Installation
This Vue plugin can be installed via npm or yarn
npm
$ npm install @eli5/vue-lang-js
yarn
$ yarn add @eli5/vue-lang-js
Initialization
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
})
Usage
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')
Related Packages
duplicate-dependencies-webpack-plugin
webpack plugin to find duplicated dependencies from your bundle
332,104
6
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.3.1 | ^2.1.10 | MIT | |
| 1.3.0 | ^2.1.10 | MIT | |
| 1.2.0 | ^2.1.10 | MIT | |
| 1.1.6 | ^2.1.10 | MIT | |
| 1.1.5 | ^2.1.10 | MIT | |
| 1.1.4 | ^2.1.10 | MIT | |
| 1.1.3 | ^2.1.10 | MIT | |
| 1.1.2 | ^2.1.10 | MIT | |
| 1.1.1 | ^2.1.10 | MIT | |
| 1.1.0 | ^2.1.10 | MIT | |
| 1.0.3 | ^2.1.10 | MIT | |
| 0.1.0 | ^2.1.10 | MIT | |
| 0.0.1 | ^2.1.10 | MIT |