mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 07:57:56 +03:00
Improved --translate feature.
This commit is contained in:
parent
ffb61443ec
commit
21162cab72
@ -183,10 +183,18 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
for (var i in files) {
|
for (var i in files) {
|
||||||
var file = obj.path.join(obj.webViewsOverridePath, files[i]);
|
var file = obj.path.join(obj.webViewsOverridePath, files[i]);
|
||||||
if (file.endsWith('.handlebars') && !file.endsWith('-min.handlebars')) {
|
if (file.endsWith('.handlebars') && !file.endsWith('-min.handlebars')) {
|
||||||
|
translateEngine.startEx(['', '', 'minify', file]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
files = obj.fs.readdirSync(obj.webViewsOverridePath);
|
||||||
|
for (var i in files) {
|
||||||
|
var file = obj.path.join(obj.webViewsOverridePath, files[i]);
|
||||||
|
if (file.endsWith('.handlebars') || file.endsWith('-min.handlebars')) {
|
||||||
translateEngine.startEx(['', '', 'translate', '*', translationFile, file, '--subdir:translations']);
|
translateEngine.startEx(['', '', 'translate', '*', translationFile, file, '--subdir:translations']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (obj.webPublicOverridePath != null) {
|
if (obj.webPublicOverridePath != null) {
|
||||||
didSomething = true;
|
didSomething = true;
|
||||||
var files = obj.fs.readdirSync(obj.webPublicOverridePath);
|
var files = obj.fs.readdirSync(obj.webPublicOverridePath);
|
||||||
@ -197,6 +205,7 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (didSomething == false) { console.log("Nothing to do."); }
|
if (didSomething == false) { console.log("Nothing to do."); }
|
||||||
process.exit();
|
process.exit();
|
||||||
|
@ -99,7 +99,7 @@ function startEx(argv) {
|
|||||||
|
|
||||||
var command = null;
|
var command = null;
|
||||||
if (argv.length > 2) { command = argv[2].toLowerCase(); }
|
if (argv.length > 2) { command = argv[2].toLowerCase(); }
|
||||||
if (['check', 'extract', 'extractall', 'translate', 'translateall', 'minifyall', 'merge', 'totext', 'fromtext'].indexOf(command) == -1) { command = null; }
|
if (['minify', 'check', 'extract', 'extractall', 'translate', 'translateall', 'minifyall', 'merge', 'totext', 'fromtext'].indexOf(command) == -1) { command = null; }
|
||||||
|
|
||||||
if (directRun) { log('MeshCentral web site translator'); }
|
if (directRun) { log('MeshCentral web site translator'); }
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
@ -283,6 +283,42 @@ function startEx(argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == 'minify') {
|
||||||
|
var outname = argv[3];
|
||||||
|
var outnamemin = null;
|
||||||
|
if (outname.endsWith('.handlebars')) {
|
||||||
|
outnamemin = (outname.substring(0, outname.length - 11) + '-min.handlebars');
|
||||||
|
} else if (outname.endsWith('.html')) {
|
||||||
|
outnamemin = (outname.substring(0, outname.length - 5) + '-min.html');
|
||||||
|
} else if (outname.endsWith('.htm')) {
|
||||||
|
outnamemin = (outname.substring(0, outname.length - 4) + '-min.htm');
|
||||||
|
} else {
|
||||||
|
outnamemin = (outname, outname + '.min');
|
||||||
|
}
|
||||||
|
log('Generating ' + path.basename(outnamemin) + '...');
|
||||||
|
|
||||||
|
// Minify the file
|
||||||
|
if (minifyLib = 2) {
|
||||||
|
var minifiedOut = minify(fs.readFileSync(outname).toString(), {
|
||||||
|
collapseBooleanAttributes: true,
|
||||||
|
collapseInlineTagWhitespace: false, // This is not good.
|
||||||
|
collapseWhitespace: true,
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyJS: true,
|
||||||
|
removeComments: true,
|
||||||
|
removeOptionalTags: true,
|
||||||
|
removeEmptyAttributes: true,
|
||||||
|
removeAttributeQuotes: true,
|
||||||
|
removeRedundantAttributes: true,
|
||||||
|
removeScriptTypeAttributes: true,
|
||||||
|
removeTagWhitespace: true,
|
||||||
|
preserveLineBreaks: false,
|
||||||
|
useShortDoctype: true
|
||||||
|
});
|
||||||
|
fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -474,7 +510,7 @@ function extract(langFile, sources) {
|
|||||||
}
|
}
|
||||||
fs.writeFileSync(langFile, translationsToJson({ strings: output }), { flag: 'w+' });
|
fs.writeFileSync(langFile, translationsToJson({ strings: output }), { flag: 'w+' });
|
||||||
log(format("{0} strings in output file.", count));
|
log(format("{0} strings in output file.", count));
|
||||||
process.exit();
|
//process.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user