Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pespantelis/vue-localizer
:earth_africa: Localization plugin for Vue.js
https://github.com/pespantelis/vue-localizer
Last synced: 17 days ago
JSON representation
:earth_africa: Localization plugin for Vue.js
- Host: GitHub
- URL: https://github.com/pespantelis/vue-localizer
- Owner: pespantelis
- License: mit
- Archived: true
- Created: 2016-04-30T15:38:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-07T21:02:47.000Z (over 8 years ago)
- Last Synced: 2024-09-26T01:38:09.470Z (about 2 months ago)
- Language: JavaScript
- Homepage: http://pespantelis.github.io/vue-localizer/
- Size: 97.7 KB
- Stars: 40
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Localizer
## Installation
### Install via NPM
Available through npm as `vue-localizer`.
```
npm install --save vue-localizer
```## Usage
You can set the locales globally or.. into each component separately!- Firsty it checks about the given path into the component's locales.
- If it exist, returns the specified text.
- Otherwise it checks into the global locales and if it does not exist, it returns the path.#### Create a new Localizer instance
```js
import VueLocalizer from 'vue-localizer'// install
Vue.use(VueLocalizer)// the constructor comes with 2 optional arguments:
// - globalLocales (default: {})
// - language (default: 'en')
var localizer = new VueLocalizer()
```#### You can add before/after change hooks
```js
localizer.beforeChange((lang) => {})
localizer.afterChange((lang) => {})
```#### Add locales to your components if you want
```js
export default {
data: {..},locales: {
en: {
name: {
first: 'Pantelis',
last: '{0}'
full: '{first} {last}',
}
},
el: {..},
..
},methods: {..}
}
```#### Change the language
```js
this.$lang.change('el') // call it from a vue instance
```#### Template
```html{{ $lang('name.first') }}
{{ $lang('name.last', ['Peslis']) }}
{{ $lang('name.full', {first:'Pantelis',last:'Peslis'}) }}
```## License
Localizer is released under the MIT License. See the bundled LICENSE file for details.