2020-02-16 18:30:00 +00:00
|
|
|
// import the styles
|
|
|
|
import Vue from 'vue'
|
|
|
|
import App from './App.vue'
|
|
|
|
import router from './router/index'
|
|
|
|
import store from './store/index'
|
2020-11-24 02:53:49 +00:00
|
|
|
// import 'material-design-icons/iconfont/material-icons.css'
|
2020-02-16 18:30:00 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import { fas } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
2020-08-06 03:39:00 +00:00
|
|
|
import VueI18n from 'vue-i18n'
|
|
|
|
import yaml from 'js-yaml'
|
|
|
|
import fs from 'fs'
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
const isDev = process.env.NODE_ENV === 'development'
|
|
|
|
|
|
|
|
Vue.config.devtools = isDev
|
|
|
|
Vue.config.performance = isDev
|
|
|
|
Vue.config.productionTip = isDev
|
|
|
|
|
|
|
|
library.add(fas)
|
|
|
|
|
2020-10-04 18:30:54 +00:00
|
|
|
Vue.component('FontAwesomeIcon', FontAwesomeIcon)
|
2020-08-06 03:39:00 +00:00
|
|
|
Vue.use(VueI18n)
|
|
|
|
|
|
|
|
// List of locales approved for use
|
2020-10-11 15:25:07 +00:00
|
|
|
const activeLocales = ['en-US', 'en_GB', 'ar', 'bg', 'da', 'de-DE', 'el', 'es', 'es-MX', 'fi', 'fr-FR', 'he', 'hu', 'hr', 'id', 'it', 'ja', 'nl', 'pl', 'pt', 'pt-BR', 'pt-PT', 'ru', 'sl', 'sv', 'tr', 'vi', 'zh-CN', 'zh-TW']
|
2020-08-06 03:39:00 +00:00
|
|
|
const messages = {}
|
2020-10-27 17:47:40 +00:00
|
|
|
/* eslint-disable-next-line */
|
2020-08-25 14:18:14 +00:00
|
|
|
const fileLocation = isDev ? 'static/locales/' : `${__dirname}/static/locales/`
|
2020-08-06 03:39:00 +00:00
|
|
|
|
|
|
|
// Take active locales and load respective YAML file
|
|
|
|
activeLocales.forEach((locale) => {
|
|
|
|
try {
|
|
|
|
// File location when running in dev
|
2020-08-25 14:18:14 +00:00
|
|
|
const doc = yaml.safeLoad(fs.readFileSync(`${fileLocation}${locale}.yaml`))
|
2020-08-06 03:39:00 +00:00
|
|
|
messages[locale] = doc
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const i18n = new VueI18n({
|
|
|
|
locale: 'en-US', // set locale
|
2020-08-12 03:26:49 +00:00
|
|
|
fallbackLocale: {
|
|
|
|
default: 'en-US'
|
|
|
|
},
|
2020-08-06 03:39:00 +00:00
|
|
|
messages // set locale messages
|
|
|
|
})
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
/* eslint-disable-next-line */
|
|
|
|
new Vue({
|
|
|
|
el: '#app',
|
|
|
|
router,
|
|
|
|
store,
|
2020-08-06 03:39:00 +00:00
|
|
|
i18n,
|
2020-02-16 18:30:00 +00:00
|
|
|
render: h => h(App)
|
|
|
|
})
|
|
|
|
|
2020-03-24 13:22:29 +00:00
|
|
|
// to avoild accesing electorn api from web app build
|
|
|
|
if (window && window.process && window.process.type === 'renderer') {
|
|
|
|
const { ipcRenderer } = require('electron')
|
|
|
|
|
|
|
|
// handle menu event updates from main script
|
|
|
|
ipcRenderer.on('change-view', (event, data) => {
|
|
|
|
if (data.route) {
|
|
|
|
router.push(data.route)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|