fix meshcentral-web-domain translate displaying (#6180)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
0a89d07937
commit
482e79f913
64
webserver.js
64
webserver.js
|
@ -8972,9 +8972,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||||
if (obj.renderPages != null) {
|
if (obj.renderPages != null) {
|
||||||
// Get the list of acceptable languages in order
|
// Get the list of acceptable languages in order
|
||||||
var acceptLanguages = obj.getLanguageCodes(req);
|
var acceptLanguages = obj.getLanguageCodes(req);
|
||||||
|
var domain = getDomain(req);
|
||||||
// Take a look at the options we have for this file
|
// Take a look at the options we have for this file
|
||||||
var fileOptions = obj.renderPages[obj.path.basename(filename)];
|
var fileOptions = obj.renderPages[domain.id][obj.path.basename(filename)];
|
||||||
if (fileOptions != null) {
|
if (fileOptions != null) {
|
||||||
for (var i in acceptLanguages) {
|
for (var i in acceptLanguages) {
|
||||||
if ((acceptLanguages[i] == 'en') || (acceptLanguages[i].startsWith('en-'))) {
|
if ((acceptLanguages[i] == 'en') || (acceptLanguages[i].startsWith('en-'))) {
|
||||||
|
@ -9021,36 +9021,58 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||||
if (translateFolder != null) {
|
if (translateFolder != null) {
|
||||||
obj.renderPages = {};
|
obj.renderPages = {};
|
||||||
obj.renderLanguages = ['en'];
|
obj.renderLanguages = ['en'];
|
||||||
var files = obj.fs.readdirSync(translateFolder);
|
for (var i in parent.config.domains) {
|
||||||
for (var i in files) {
|
if (obj.fs.existsSync('views/translations')) { translateFolder = 'views/translations'; }
|
||||||
var name = files[i];
|
if (obj.fs.existsSync(obj.path.join(__dirname, 'views', 'translations'))) { translateFolder = obj.path.join(__dirname, 'views', 'translations'); }
|
||||||
if (name.endsWith('.handlebars')) {
|
|
||||||
name = name.substring(0, name.length - 11);
|
|
||||||
var xname = name.split('_');
|
|
||||||
if (xname.length == 2) {
|
|
||||||
if (obj.renderPages[xname[0]] == null) { obj.renderPages[xname[0]] = {}; }
|
|
||||||
obj.renderPages[xname[0]][xname[1]] = obj.path.join(translateFolder, name);
|
|
||||||
if (obj.renderLanguages.indexOf(xname[1]) == -1) { obj.renderLanguages.push(xname[1]); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See if there are any custom rending pages that will override the default ones
|
|
||||||
if ((obj.parent.webViewsOverridePath != null) && (obj.fs.existsSync(obj.path.join(obj.parent.webViewsOverridePath, 'translations')))) {
|
|
||||||
translateFolder = obj.path.join(obj.parent.webViewsOverridePath, 'translations');
|
|
||||||
var files = obj.fs.readdirSync(translateFolder);
|
var files = obj.fs.readdirSync(translateFolder);
|
||||||
|
var domain = parent.config.domains[i].id;
|
||||||
|
obj.renderPages[domain] = {};
|
||||||
for (var i in files) {
|
for (var i in files) {
|
||||||
var name = files[i];
|
var name = files[i];
|
||||||
if (name.endsWith('.handlebars')) {
|
if (name.endsWith('.handlebars')) {
|
||||||
name = name.substring(0, name.length - 11);
|
name = name.substring(0, name.length - 11);
|
||||||
var xname = name.split('_');
|
var xname = name.split('_');
|
||||||
if (xname.length == 2) {
|
if (xname.length == 2) {
|
||||||
if (obj.renderPages[xname[0]] == null) { obj.renderPages[xname[0]] = {}; }
|
if (obj.renderPages[domain][xname[0]] == null) { obj.renderPages[domain][xname[0]] = {}; }
|
||||||
obj.renderPages[xname[0]][xname[1]] = obj.path.join(translateFolder, name);
|
obj.renderPages[domain][xname[0]][xname[1]] = obj.path.join(translateFolder, name);
|
||||||
if (obj.renderLanguages.indexOf(xname[1]) == -1) { obj.renderLanguages.push(xname[1]); }
|
if (obj.renderLanguages.indexOf(xname[1]) == -1) { obj.renderLanguages.push(xname[1]); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// See if there are any custom rending pages that will override the default ones
|
||||||
|
if ((obj.parent.webViewsOverridePath != null) && (obj.fs.existsSync(obj.path.join(obj.parent.webViewsOverridePath, 'translations')))) {
|
||||||
|
translateFolder = obj.path.join(obj.parent.webViewsOverridePath, 'translations');
|
||||||
|
var files = obj.fs.readdirSync(translateFolder);
|
||||||
|
for (var i in files) {
|
||||||
|
var name = files[i];
|
||||||
|
if (name.endsWith('.handlebars')) {
|
||||||
|
name = name.substring(0, name.length - 11);
|
||||||
|
var xname = name.split('_');
|
||||||
|
if (xname.length == 2) {
|
||||||
|
if (obj.renderPages[domain][xname[0]] == null) { obj.renderPages[domain][xname[0]] = {}; }
|
||||||
|
obj.renderPages[domain][xname[0]][xname[1]] = obj.path.join(translateFolder, name);
|
||||||
|
if (obj.renderLanguages.indexOf(xname[1]) == -1) { obj.renderLanguages.push(xname[1]); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// See if there is a custom meshcentral-web-domain folder as that will override the default ones
|
||||||
|
if (obj.fs.existsSync(obj.path.join(__dirname, '..', 'meshcentral-web-' + domain, 'views', 'translations'))) {
|
||||||
|
translateFolder = obj.path.join(__dirname, '..', 'meshcentral-web-' + domain, 'views', 'translations');
|
||||||
|
var files = obj.fs.readdirSync(translateFolder);
|
||||||
|
for (var i in files) {
|
||||||
|
var name = files[i];
|
||||||
|
if (name.endsWith('.handlebars')) {
|
||||||
|
name = name.substring(0, name.length - 11);
|
||||||
|
var xname = name.split('_');
|
||||||
|
if (xname.length == 2) {
|
||||||
|
if (obj.renderPages[domain][xname[0]] == null) { obj.renderPages[domain][xname[0]] = {}; }
|
||||||
|
obj.renderPages[domain][xname[0]][xname[1]] = obj.path.join(translateFolder, name);
|
||||||
|
if (obj.renderLanguages.indexOf(xname[1]) == -1) { obj.renderLanguages.push(xname[1]); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue