Skip to content

Commit

Permalink
Vue 1 is now supported
Browse files Browse the repository at this point in the history
  • Loading branch information
javisperez committed Aug 29, 2016
1 parent 520f31c commit fbded9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## VueTranslate

A VueJS (2.0+) plugin for basic translations.
A VueJS (1.x, 2.0+) plugin for basic translations.

### What is this?

Expand All @@ -14,10 +14,6 @@ Yes and no, Vue-i18n is a great plugin and is a lot more complete than this. Thi

Just translations, it is that simple.

### Why VueJS v2.0 only?

Because it's the current version i'm using, so i haven't test it on VueJS 1.x but i think it won't work because the "init()" method is called "beforeCreate()" on VueJS 2.x.

## Example
```javascript
import Vue from 'vue';
Expand Down
5 changes: 3 additions & 2 deletions dist/vue-translate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-translate-plugin",
"version": "1.0.0",
"description": "Basic translations plugins for VueJS v2.0+",
"version": "1.0.3",
"description": "Basic translations plugins for VueJS (1.x, 2.0)",
"main": "dist/vue-translate.min.js",
"files": [
"dist/vue.common.js",
Expand Down
8 changes: 5 additions & 3 deletions vue-translate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* VueTranslate plugin
*
* Handle basic translations in VueJS 2.0
* Handle basic translations in VueJS
*
* This is a plugin to handle basic translations for a component in VueJS.
*
Expand All @@ -19,6 +19,8 @@ function VueTranslate() {}

// Install the method
VueTranslate.install = function (Vue) {
let version = Vue.version[0];

if (!vm) {
vm = new Vue({
data() {
Expand Down Expand Up @@ -73,7 +75,7 @@ VueTranslate.install = function (Vue) {

// Mixin to read locales and add the translation method and directive
Vue.mixin({
beforeCreate() {
[version === '1' ? 'init' : 'beforeCreate']() {
this.$translate.setLocales(this.$options.locales);
},

Expand Down Expand Up @@ -103,4 +105,4 @@ if (typeof exports === 'object') {
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}
}

0 comments on commit fbded9c

Please sign in to comment.