translation fixes for meshcentral-data-domain (#6027)

* dont translate min files
* translate meshcentral-web-domain folders with --translate
* also translate default views folder incase of changes

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-04-15 13:00:42 +01:00 committed by GitHub
parent f854c80421
commit 30d570f28b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -220,6 +220,12 @@ function CreateMeshCentralServer(config, args) {
translateEngine.startEx(['', '', 'translateall', translationFile]);
translateEngine.startEx(['', '', 'extractall', translationFile]);
didSomething = true;
} else {
// Translate all of the default files
translateEngine.startEx(['', '', 'minifyall']);
translateEngine.startEx(['', '', 'translateall']);
translateEngine.startEx(['', '', 'extractall']);
didSomething = true;
}
// Check if "meshcentral-web" exists, if so, translate all pages in that folder.
@ -235,11 +241,34 @@ function CreateMeshCentralServer(config, args) {
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')) {
if (file.endsWith('.handlebars') && !file.endsWith('-min.handlebars')) {
translateEngine.startEx(['', '', 'translate', '*', translationFile, file, '--subdir:translations']);
}
}
}
// Check domains and see if "meshcentral-web-DOMAIN" exists, if so, translate all pages in that folder
for (i in obj.config.domains) {
if (i == "") continue;
var path = obj.path.join(obj.datapath, '..', 'meshcentral-web-' + i, 'views');
if (require('fs').existsSync(path)) {
didSomething = true;
var files = obj.fs.readdirSync(path);
for (var a in files) {
var file = obj.path.join(path, files[a]);
if (file.endsWith('.handlebars') && !file.endsWith('-min.handlebars')) {
translateEngine.startEx(['', '', 'minify', file]);
}
}
files = obj.fs.readdirSync(path);
for (var a in files) {
var file = obj.path.join(path, files[a]);
if (file.endsWith('.handlebars') && !file.endsWith('-min.handlebars')) {
translateEngine.startEx(['', '', 'translate', '*', translationFile, file, '--subdir:translations']);
}
}
}
}
/*
if (obj.webPublicOverridePath != null) {
didSomething = true;
@ -254,6 +283,7 @@ function CreateMeshCentralServer(config, args) {
*/
if (didSomething == false) { console.log("Nothing to do."); }
console.log('Finished Translating.')
process.exit();
return;
}