-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to fix a bug when building with Laravel Elixir with the --prod…
…uction flag Signed-off-by: Javis Perez <[email protected]>
- Loading branch information
1 parent
a6d4ae2
commit 83b2678
Showing
10 changed files
with
534 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var fs = require('fs'); | ||
var rollup = require('rollup'); | ||
var uglify = require('uglify-js'); | ||
var babel = require('rollup-plugin-babel'); | ||
var package = require('../package.json'); | ||
var banner = | ||
"/**\n" + | ||
" * VueTranslate plugin v" + package.version + "\n" + | ||
" *\n"+ | ||
" * Handle basic translations in VueJS\n"+ | ||
" *\n"+ | ||
" * This is a plugin to handle basic translations for a component in VueJS."+ | ||
" * @author Javis Perez <[email protected]>\n"+ | ||
" * https://github.com/javisperez/vuetranslate\n"+ | ||
" * Released under the MIT License.\n" + | ||
" */\n"; | ||
|
||
rollup.rollup({ | ||
entry: 'src/vue-translate.js', | ||
plugins: [ | ||
babel({ | ||
presets: ['es2015-loose-rollup'] | ||
}) | ||
] | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue-translate.js', bundle.generate({ | ||
format: 'umd', | ||
banner: banner, | ||
moduleName: 'VueTranslate' | ||
}).code, bundle); | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue-translate.min.js', | ||
banner + '\n' + uglify.minify('dist/vue-translate.js').code, | ||
bundle); | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue-translate.es2015.js', bundle.generate({ | ||
banner: banner, | ||
footer: 'export { Url, Http, Resource };' | ||
}).code, bundle); | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue-translate.common.js', bundle.generate({ | ||
format: 'cjs', | ||
banner: banner | ||
}).code, bundle); | ||
}) | ||
.catch(logError); | ||
|
||
function write(dest, code, bundle) { | ||
return new Promise(function (resolve, reject) { | ||
fs.writeFile(dest, code, function (err) { | ||
if (err) return reject(err); | ||
console.log(blue(dest) + ' ' + getSize(code)); | ||
resolve(bundle); | ||
}); | ||
}); | ||
} | ||
|
||
function getSize(code) { | ||
return (code.length / 1024).toFixed(2) + 'kb'; | ||
} | ||
|
||
function logError(e) { | ||
console.log(e); | ||
} | ||
|
||
function blue(str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* VueTranslate plugin v1.1.0 | ||
* | ||
* Handle basic translations in VueJS | ||
* | ||
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]> | ||
* https://github.com/javisperez/vuetranslate | ||
* Released under the MIT License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// We need a vue instance to handle reactivity | ||
var vm = null; | ||
|
||
// The plugin | ||
var VueTranslate = { | ||
|
||
// Install the method | ||
|
||
install: function (Vue) { | ||
var _Vue$mixin; | ||
|
||
var version = Vue.version[0]; | ||
|
||
if (!vm) { | ||
vm = new Vue({ | ||
data: function () { | ||
return { | ||
current: '', | ||
locales: {} | ||
}; | ||
}, | ||
|
||
|
||
computed: { | ||
locale: function () { | ||
if (!this.locales[this.current]) return null; | ||
|
||
return this.locales[this.current]; | ||
} | ||
}, | ||
|
||
methods: { | ||
setLang: function (val) { | ||
this.current = val; | ||
}, | ||
setLocales: function (locales) { | ||
if (!locales) return; | ||
|
||
var newLocale = Object.create(this.locales); | ||
|
||
for (var key in locales) { | ||
if (!newLocale[key]) newLocale[key] = {}; | ||
|
||
Vue.util.extend(newLocale[key], locales[key]); | ||
} | ||
|
||
this.locales = Object.create(newLocale); | ||
}, | ||
text: function (t) { | ||
if (!this.locale || !this.locale[t]) { | ||
return t; | ||
} | ||
|
||
return this.locale[t]; | ||
} | ||
} | ||
}); | ||
|
||
Vue.prototype.$translate = vm; | ||
} | ||
|
||
// Mixin to read locales and add the translation method and directive | ||
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () { | ||
this.$translate.setLocales(this.$options.locales); | ||
}, _Vue$mixin.methods = { | ||
t: function (t) { | ||
return this.$translate.text(t); | ||
} | ||
}, _Vue$mixin.directives = { | ||
translate: function (el) { | ||
if (!el.$translateKey) el.$translateKey = el.innerText; | ||
|
||
var text = this.$translate.text(el.$translateKey); | ||
|
||
el.innerText = text; | ||
}.bind(vm) | ||
}, _Vue$mixin)); | ||
} | ||
}; | ||
|
||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* VueTranslate plugin v1.1.0 | ||
* | ||
* Handle basic translations in VueJS | ||
* | ||
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]> | ||
* https://github.com/javisperez/vuetranslate | ||
* Released under the MIT License. | ||
*/ | ||
|
||
// We need a vue instance to handle reactivity | ||
var vm = null; | ||
|
||
// The plugin | ||
var VueTranslate = { | ||
|
||
// Install the method | ||
|
||
install: function (Vue) { | ||
var _Vue$mixin; | ||
|
||
var version = Vue.version[0]; | ||
|
||
if (!vm) { | ||
vm = new Vue({ | ||
data: function () { | ||
return { | ||
current: '', | ||
locales: {} | ||
}; | ||
}, | ||
|
||
|
||
computed: { | ||
locale: function () { | ||
if (!this.locales[this.current]) return null; | ||
|
||
return this.locales[this.current]; | ||
} | ||
}, | ||
|
||
methods: { | ||
setLang: function (val) { | ||
this.current = val; | ||
}, | ||
setLocales: function (locales) { | ||
if (!locales) return; | ||
|
||
var newLocale = Object.create(this.locales); | ||
|
||
for (var key in locales) { | ||
if (!newLocale[key]) newLocale[key] = {}; | ||
|
||
Vue.util.extend(newLocale[key], locales[key]); | ||
} | ||
|
||
this.locales = Object.create(newLocale); | ||
}, | ||
text: function (t) { | ||
if (!this.locale || !this.locale[t]) { | ||
return t; | ||
} | ||
|
||
return this.locale[t]; | ||
} | ||
} | ||
}); | ||
|
||
Vue.prototype.$translate = vm; | ||
} | ||
|
||
// Mixin to read locales and add the translation method and directive | ||
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () { | ||
this.$translate.setLocales(this.$options.locales); | ||
}, _Vue$mixin.methods = { | ||
t: function (t) { | ||
return this.$translate.text(t); | ||
} | ||
}, _Vue$mixin.directives = { | ||
translate: function (el) { | ||
if (!el.$translateKey) el.$translateKey = el.innerText; | ||
|
||
var text = this.$translate.text(el.$translateKey); | ||
|
||
el.innerText = text; | ||
}.bind(vm) | ||
}, _Vue$mixin)); | ||
} | ||
}; | ||
|
||
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); | ||
} | ||
export { Url, Http, Resource }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* VueTranslate plugin v1.1.0 | ||
* | ||
* Handle basic translations in VueJS | ||
* | ||
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]> | ||
* https://github.com/javisperez/vuetranslate | ||
* Released under the MIT License. | ||
*/ | ||
|
||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(factory()); | ||
}(this, (function () { 'use strict'; | ||
|
||
// We need a vue instance to handle reactivity | ||
var vm = null; | ||
|
||
// The plugin | ||
var VueTranslate = { | ||
|
||
// Install the method | ||
|
||
install: function (Vue) { | ||
var _Vue$mixin; | ||
|
||
var version = Vue.version[0]; | ||
|
||
if (!vm) { | ||
vm = new Vue({ | ||
data: function () { | ||
return { | ||
current: '', | ||
locales: {} | ||
}; | ||
}, | ||
|
||
|
||
computed: { | ||
locale: function () { | ||
if (!this.locales[this.current]) return null; | ||
|
||
return this.locales[this.current]; | ||
} | ||
}, | ||
|
||
methods: { | ||
setLang: function (val) { | ||
this.current = val; | ||
}, | ||
setLocales: function (locales) { | ||
if (!locales) return; | ||
|
||
var newLocale = Object.create(this.locales); | ||
|
||
for (var key in locales) { | ||
if (!newLocale[key]) newLocale[key] = {}; | ||
|
||
Vue.util.extend(newLocale[key], locales[key]); | ||
} | ||
|
||
this.locales = Object.create(newLocale); | ||
}, | ||
text: function (t) { | ||
if (!this.locale || !this.locale[t]) { | ||
return t; | ||
} | ||
|
||
return this.locale[t]; | ||
} | ||
} | ||
}); | ||
|
||
Vue.prototype.$translate = vm; | ||
} | ||
|
||
// Mixin to read locales and add the translation method and directive | ||
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () { | ||
this.$translate.setLocales(this.$options.locales); | ||
}, _Vue$mixin.methods = { | ||
t: function (t) { | ||
return this.$translate.text(t); | ||
} | ||
}, _Vue$mixin.directives = { | ||
translate: function (el) { | ||
if (!el.$translateKey) el.$translateKey = el.innerText; | ||
|
||
var text = this.$translate.text(el.$translateKey); | ||
|
||
el.innerText = text; | ||
}.bind(vm) | ||
}, _Vue$mixin)); | ||
} | ||
}; | ||
|
||
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); | ||
} | ||
|
||
}))); |
Oops, something went wrong.