mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2025-02-03 05:33:23 +00:00
Probs with Async Await
This commit is contained in:
parent
3fe0839f07
commit
238e4b50e2
4 changed files with 125 additions and 14 deletions
|
@ -4,7 +4,7 @@ import VueI18n from 'vue-i18n'
|
|||
Vue.use(VueI18n)
|
||||
|
||||
function loadLocaleMessages () {
|
||||
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
|
||||
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
|
||||
const messages = {}
|
||||
locales.keys().forEach(key => {
|
||||
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
|
||||
|
|
31
src/main.js
31
src/main.js
|
@ -4,8 +4,7 @@ import Vuex from "vuex"
|
|||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import {wtutils, wtconfig} from './wtutils'
|
||||
|
||||
import {wtutils, wtconfig, poeditor} from './wtutils'
|
||||
|
||||
/*Icons - Styling - Design Frameworks - Sidemenu*/
|
||||
import Buefy from 'buefy'
|
||||
|
@ -24,7 +23,7 @@ Vue.use(Buefy);
|
|||
// Logging start
|
||||
// Remember to define log in all components where its used, as in below
|
||||
const log = require('electron-log');
|
||||
log.transports.file.level = 'info';
|
||||
log.transports.file.level = 'verbose';
|
||||
log.transports.console.level = 'verbose';
|
||||
log.transports.file.fileName = wtutils.AppName;
|
||||
console.log = log.log;
|
||||
|
@ -32,7 +31,31 @@ log.info('*********************************')
|
|||
log.info('Starting ' + wtutils.AppName + ' Version:' + wtutils.AppVersion);
|
||||
// Logging ended
|
||||
|
||||
wtutils.MoveToHome('./public/locales');
|
||||
// Where translation files are located
|
||||
var localHome = '';
|
||||
if (wtutils.isDev)
|
||||
{
|
||||
localHome = __dirname.replace('node_modules/electron/dist/resources/electron.asar/renderer', 'public/locales');
|
||||
}
|
||||
else
|
||||
{
|
||||
localHome = __dirname.replace('app.asar', 'locales');
|
||||
}
|
||||
console.log('localesHome: ' + localHome);
|
||||
wtutils.MoveToHome(localHome);
|
||||
|
||||
const Translators = poeditor.Translators;
|
||||
console.log('Ged her1');
|
||||
console.log('Ged her2 ' + Translators);
|
||||
|
||||
|
||||
|
||||
Translators.forEach(element => {
|
||||
console.log('Ged Name: ' + element.name);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Get saved language to use, and default to en
|
||||
|
|
|
@ -4,7 +4,10 @@ that we use in our solution.
|
|||
Can be used both from rendering and from main
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
const qs = require('querystring')
|
||||
const log = require('electron-log');
|
||||
const electron = require('electron');
|
||||
// User Config
|
||||
const Store = require('electron-store');
|
||||
|
@ -43,23 +46,29 @@ const wtutils = new class WTUtils {
|
|||
return (electron.app || electron.remote.app).getVersion();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
This will move translation files in the app to userdata
|
||||
directory in a sub-folder named locales
|
||||
It will only do so if this has not been done before or
|
||||
this is a new version of our app
|
||||
*/
|
||||
MoveToHome(SourceDir) {
|
||||
var last = wtconfig.get('general.transfilescopied', "0")
|
||||
if (!(last == wtutils.AppVersion))
|
||||
{
|
||||
console.log('We need to copy translation strings over')
|
||||
log.debug('We need to copy translation strings over')
|
||||
var fs = require('fs');
|
||||
// Check if userdata/locales exists, and create if not
|
||||
var TargetDir = wtutils.Home + '/locales';
|
||||
if (!fs.existsSync(TargetDir)){
|
||||
log.debug('locales directory needs to be created');
|
||||
fs.mkdirSync(TargetDir);
|
||||
}
|
||||
fs.readdir(SourceDir, function(err, items) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
var SourceFile = SourceDir + '/' + items[i];
|
||||
var TargetFile = TargetDir + '/' + items[i];
|
||||
log.debug('Copying ' + SourceFile + ' to ' + TargetFile);
|
||||
fs.copyFile(SourceFile, TargetFile, err => {
|
||||
if (err) return console.error(err)
|
||||
});
|
||||
|
@ -76,11 +85,77 @@ const wtutils = new class WTUtils {
|
|||
}
|
||||
this._name = value;
|
||||
} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const poeditor = new class POEditor {
|
||||
constructor() {
|
||||
this.requestBody = {
|
||||
id: '342617',
|
||||
api_token: '5166c4294ff7fb3a82cbdc82958e850e'
|
||||
}
|
||||
|
||||
this.config = {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
get Translators() {
|
||||
var result = [];
|
||||
|
||||
axios.post('https://api.poeditor.com/v2/contributors/list', qs.stringify(this.requestBody), this.config)
|
||||
.then((response) => {
|
||||
var fresponse = response.data.result.contributors;
|
||||
fresponse.forEach(element => {
|
||||
result.push(element.name);
|
||||
|
||||
log.verbose('Translator name: ' + element.name)
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
.then((fresponse) => {
|
||||
console.log('2nd then: ' + fresponse)
|
||||
return fresponse
|
||||
|
||||
})
|
||||
|
||||
console.log('Ged Result: ' + result)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
get Languages() {
|
||||
var fresponse = null;
|
||||
axios.post('https://api.poeditor.com/v2/languages/list', qs.stringify(this.requestBody), this.config)
|
||||
.then((response) => {
|
||||
console.log(response.data.result)
|
||||
/* response.forEach(element => {
|
||||
console.log('Ged Navn: ' + element.name);
|
||||
}) */
|
||||
|
||||
fresponse = response.data.result
|
||||
})
|
||||
return fresponse
|
||||
|
||||
/* {
|
||||
"name": "Danish",
|
||||
"code": "da",
|
||||
"translations": 39,
|
||||
"percentage": 68,
|
||||
"updated": "2020-06-03T22:24:11+0000"
|
||||
} */
|
||||
}
|
||||
|
||||
UpdateLang() {
|
||||
poeditor.Languages.forEach(element => {
|
||||
console.log('Ged Sprog: ' + element.name);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export {wtutils, wtconfig};
|
||||
}
|
||||
export {wtutils, wtconfig, poeditor};
|
|
@ -5,6 +5,19 @@ module.exports = {
|
|||
fallbackLocale: 'en',
|
||||
localeDir: 'locales',
|
||||
enableInSFC: false
|
||||
},
|
||||
electronBuilder: {
|
||||
builderOptions: {
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "./public/locales",
|
||||
"to": "locales"
|
||||
}
|
||||
],
|
||||
"linux": {
|
||||
"category": "Utility"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue