Fixed translation tools output format.

This commit is contained in:
Ylian Saint-Hilaire 2020-01-07 17:12:09 -08:00
parent f350350fc6
commit 85d4972068
7 changed files with 1124 additions and 1142 deletions

View File

@ -1131,64 +1131,45 @@ function createMeshCore(agent) {
}; };
// Remote terminal using native pipes // Remote terminal using native pipes
if (process.platform == 'win32') if (process.platform == 'win32') {
{ try {
try
{
if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { throw ('PowerShell is not supported on this version of windows'); } if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { throw ('PowerShell is not supported on this version of windows'); }
if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) {
{
// Admin Terminal // Admin Terminal
if (require('win-virtual-terminal').supported) if (require('win-virtual-terminal').supported) {
{
// ConPTY PseudoTerminal // ConPTY PseudoTerminal
// this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25); this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
// The above line is commented out, because there is a bug with ClosePseudoConsole() API, so this is the workaround
this.httprequest._dispatcher = require('win-dispatcher').dispatch({ modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (this.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
this.httprequest._dispatcher.ws = this;
this.httprequest._dispatcher.on('connection', function (c)
{
console.log('client connected');
this.ws._term = c;
c.pipe(this.ws, { dataTypeSkip: 1 });
this.ws.pipe(c, { dataTypeSkip: 1 });
});
} }
else else {
{
// Legacy Terminal // Legacy Terminal
this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25); this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
} }
} }
else else {
{
// Logged in user // Logged in user
var userPromise = require('user-sessions').enumerateUsers(); var userPromise = require('user-sessions').enumerateUsers();
userPromise.that = this; userPromise.that = this;
userPromise.then(function (u) userPromise.then(function (u) {
{
var that = this.that; var that = this.that;
if (u.Active.length > 0) if (u.Active.length > 0) {
{
var username = u.Active[0].Username; var username = u.Active[0].Username;
if (require('win-virtual-terminal').supported) if (require('win-virtual-terminal').supported) {
{
// ConPTY PseudoTerminal // ConPTY PseudoTerminal
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } }); that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
} }
else else {
{
// Legacy Terminal // Legacy Terminal
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } }); that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
} }
that.httprequest._dispatcher.ws = that; that.httprequest._dispatcher.ws = that;
that.httprequest._dispatcher.on('connection', function (c) that.httprequest._dispatcher.on('connection', function (c) {
{
console.log('client connected'); console.log('client connected');
this.ws._term = c; this.ws._term = c;
c.pipe(this.ws, { dataTypeSkip: 1 }); c.pipe(this.ws, { dataTypeSkip: 1 });
this.ws.pipe(c, { dataTypeSkip: 1 }); this.ws.pipe(c, { dataTypeSkip: 1, end: false });
this.ws.prependListener('end', function () {
if (this.httprequest._term) { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); }
});
}); });
} }
}); });
@ -1199,17 +1180,14 @@ function createMeshCore(agent) {
this.end(); this.end();
return; return;
} }
if (!this.httprequest._dispatcher) if (!this.httprequest._dispatcher) {
{
this.httprequest._term.pipe(this, { dataTypeSkip: 1 }); this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false }); this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); }); this.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); });
} }
} }
else else {
{ try {
try
{
var bash = fs.existsSync('/bin/bash') ? '/bin/bash' : false; var bash = fs.existsSync('/bin/bash') ? '/bin/bash' : false;
var sh = fs.existsSync('/bin/sh') ? '/bin/sh' : false; var sh = fs.existsSync('/bin/sh') ? '/bin/sh' : false;
var script = fs.existsSync('/usr/bin/script') ? '/usr/bin/script' : false; var script = fs.existsSync('/usr/bin/script') ? '/usr/bin/script' : false;

View File

@ -253,6 +253,7 @@ module.exports.translationsToJson = function(t) {
for (var j in el) { names.push(j); } for (var j in el) { names.push(j); }
names.sort(); names.sort();
for (var j in names) { el2[names[j]] = el[names[j]]; } for (var j in names) { el2[names[j]] = el[names[j]]; }
if (el2.xloc != null) { el2.xloc.sort(); }
arr2.push(el2); arr2.push(el2);
} }
arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; }); arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; });

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.4.6-z", "version": "0.4.7-a",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -3,3 +3,4 @@ CD ..\translate
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js minifyall C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js minifyall
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js translateall C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js translateall
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js extractall C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js extractall
pause

View File

@ -392,6 +392,7 @@
for (var j in el) { names.push(j); } for (var j in el) { names.push(j); }
names.sort(); names.sort();
for (var j in names) { el2[names[j]] = el[names[j]]; } for (var j in names) { el2[names[j]] = el[names[j]]; }
if (el2.xloc != null) { el2.xloc.sort(); }
arr2.push(el2); arr2.push(el2);
} }
arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; }); arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; });
@ -443,7 +444,7 @@
} }
function translateServer() { function translateServer() {
var x = 'Perform server translation? The MeshCentral server will reset for 10 to 30 seconds to perform this operation.'; var x = "Perform server translation? The MeshCentral server will reset for 10 to 30 seconds to perform this operation.";
setDialogMode(2, "Translate Server", 3, translateServerEx, x); setDialogMode(2, "Translate Server", 3, translateServerEx, x);
} }
@ -458,14 +459,14 @@
xdr.onload = function () { xdr.onload = function () {
var x = null; var x = null;
try { x = JSON.parse(this.responseText); } catch (ex) { } try { x = JSON.parse(this.responseText); } catch (ex) { }
if ((x == null) || (x.response == null)) { messagebox('Server Translation', 'ERROR: Unable to parse server response.'); return; } if ((x == null) || (x.response == null)) { messagebox("Server Translation", "ERROR: Unable to parse server response."); return; }
if (x.response == 'ok') { if (x.response == 'ok') {
messagebox('Server Translation', 'Server translation initiated, this will take a minute or two. Once done, you can refresh the MeshCentral web pages to see the changes.<br /><br />When ready, please mail the file "meshcentral-data/translate.json" to <a href="mailto:ylianst@gmail.com">ylianst@gmail.com</a> for inclusion on the official build.'); messagebox("Server Translation", "Server translation initiated, this will take a minute or two. Once done, you can refresh the MeshCentral web pages to see the changes.<br /><br />When ready, please mail the file \"meshcentral-data/translate.json\" to <a href=\"mailto:ylianst@gmail.com\">ylianst@gmail.com</a> for inclusion on the official build.");
} else { } else {
messagebox('Server Translation', 'ERROR: ' + x.response); messagebox("Server Translation", "ERROR: " + x.response);
} }
}; };
xdr.onerror = function () { messagebox('Translations', 'ERROR: Unable to save translations to server.'); }; xdr.onerror = function () { messagebox("Translations", "ERROR: Unable to save translations to server."); };
xdr.send(JSON.stringify({ 'action': 'translateServer', strings: translations })); xdr.send(JSON.stringify({ 'action': 'translateServer', strings: translations }));
} }

View File

@ -664,6 +664,7 @@ function translationsToJson(t) {
for (var j in el) { names.push(j); } for (var j in el) { names.push(j); }
names.sort(); names.sort();
for (var j in names) { el2[names[j]] = el[names[j]]; } for (var j in names) { el2[names[j]] = el[names[j]]; }
if (el2.xloc != null) { el2.xloc.sort(); }
arr2.push(el2); arr2.push(el2);
} }
arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; }); arr2.sort(function (a, b) { if (a.en > b.en) return 1; if (a.en < b.en) return -1; return 0; });

File diff suppressed because it is too large Load Diff