Skip to content

Commit

Permalink
package.json and dist folder
Browse files Browse the repository at this point in the history
  • Loading branch information
javisperez authored Aug 24, 2016
1 parent bc735fc commit 3dff416
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 80 deletions.
3 changes: 3 additions & 0 deletions dist/vue-translate.min.js

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

34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "vue-translate",
"version": "1.0.0",
"description": "Basic translations plugins for VueJS v2.0+",
"main": "dist/vue-translate.min.js",
"files": [
"dist/vue.common.js",
"dist/vue.js",
"dist/vue.min.js",
"src"
],
"repository": {
"type": "git",
"url": "git+https://github.com/javisperez/vuetranslate.git"
},
"keywords": [
"vue",
"vuejs",
"translate",
"vue-translate",
"vuetranslate",
"locales",
"plugin"
],
"author": {
"name": "Javis Perez",
"email": "[email protected]"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/javisperez/vuetranslate/issues"
},
"homepage": "https://github.com/javisperez/vuetranslate#readme"
}
157 changes: 77 additions & 80 deletions vue-translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,99 @@
* @author Javis Perez <[email protected]>
* https://github.com/javisperez/vuetranslate
*/
;(function () {

// We need a vue instance to handle rectivity
var vm = null;

/**
* Constructor
*/
function VueTranslate() {}

// Install the method
VueTranslate.install = function (Vue) {
if (!vm) {
vm = new Vue({
data() {
return {
current: '',
locales: {}
};
},

computed: {
locale() {
if (!this.locales[this.current])
return null;

return this.locales[this.current];
}
},
// We need a vue instance to handle rectivity
var vm = null;

methods: {
setLang(val) {
this.current = val;
},
/**
* Constructor
*/
function VueTranslate() {}

// Install the method
VueTranslate.install = function (Vue) {
if (!vm) {
vm = new Vue({
data() {
return {
current: '',
locales: {}
};
},

setLocales(locales) {
if (!locales)
return;
computed: {
locale() {
if (!this.locales[this.current])
return null;

let newLocale = Object.create(this.locales);
return this.locales[this.current];
}
},

for (let key in locales) {
if (!newLocale[key])
newLocale[key] = {};
methods: {
setLang(val) {
this.current = val;
},

Vue.util.extend(newLocale[key], locales[key]);
}
setLocales(locales) {
if (!locales)
return;

this.locales = Object.create(newLocale);
},
let newLocale = Object.create(this.locales);

text(t) {
if (!this.locale || !this.locale[t]) {
return t;
}
for (let key in locales) {
if (!newLocale[key])
newLocale[key] = {};

return this.locale[t];
Vue.util.extend(newLocale[key], locales[key]);
}
}
});

Vue.prototype.$translate = vm;
}
this.locales = Object.create(newLocale);
},

// Mixin to read locales and add the translation method and directive
Vue.mixin({
beforeCreate() {
this.$translate.setLocales(this.$options.locales);
},
text(t) {
if (!this.locale || !this.locale[t]) {
return t;
}

methods: {
t(t) {
return this.$translate.text(t);
return this.locale[t];
}
},
}
});

directives: {
translate: function (el) {
if (!el.$translateKey)
el.$translateKey = el.innerText;
Vue.prototype.$translate = vm;
}

let text = this.$translate.text(el.$translateKey);
// Mixin to read locales and add the translation method and directive
Vue.mixin({
beforeCreate() {
this.$translate.setLocales(this.$options.locales);
},

el.innerText = text;
}.bind(vm)
methods: {
t(t) {
return this.$translate.text(t);
}
});
};

if (typeof exports === 'object') {
module.exports = VueTranslate; // CommonJS
} else if (typeof define === 'function' && define.amd) {
define([], function () { return VueTranslate; }); // AMD
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}
},

})();
directives: {
translate: function (el) {
if (!el.$translateKey)
el.$translateKey = el.innerText;

let text = this.$translate.text(el.$translateKey);

el.innerText = text;
}.bind(vm)
}
});
};

if (typeof exports === 'object') {
module.exports = VueTranslate; // CommonJS
} else if (typeof define === 'function' && define.amd) {
define([], function () { return VueTranslate; }); // AMD
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}

0 comments on commit 3dff416

Please sign in to comment.