mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added translation support for Notifications and Privacy Bar
This commit is contained in:
		
							parent
							
								
									f2e20745ad
								
							
						
					
					
						commit
						545ffe3a81
					
				
					 2 changed files with 46 additions and 18 deletions
				
			
		| 
						 | 
					@ -100,7 +100,7 @@ function getCoreTranslation()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        try
 | 
					        try
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var lang = require('util-language').current;
 | 
					            var lang = require('util-language').current; 
 | 
				
			||||||
            if (coretranslations[lang] == null) { lang = lang.split('-')[0]; }
 | 
					            if (coretranslations[lang] == null) { lang = lang.split('-')[0]; }
 | 
				
			||||||
            if (coretranslations[lang] == null) { lang = 'en'; }
 | 
					            if (coretranslations[lang] == null) { lang = 'en'; }
 | 
				
			||||||
            if (coretranslations[lang] != null) { ret = coretranslations[lang]; }
 | 
					            if (coretranslations[lang] != null) { ret = coretranslations[lang]; }
 | 
				
			||||||
| 
						 | 
					@ -114,6 +114,11 @@ function getCoreTranslation()
 | 
				
			||||||
    setDefaultCoreTranslation(ret, 'terminalConsent', '{0} requesting remote terminal access. Grant access?');
 | 
					    setDefaultCoreTranslation(ret, 'terminalConsent', '{0} requesting remote terminal access. Grant access?');
 | 
				
			||||||
    setDefaultCoreTranslation(ret, 'desktopConsent', '{0} requesting remote desktop access. Grant access?');
 | 
					    setDefaultCoreTranslation(ret, 'desktopConsent', '{0} requesting remote desktop access. Grant access?');
 | 
				
			||||||
    setDefaultCoreTranslation(ret, 'fileConsent', '{0} requesting remote file Access. Grant access?');
 | 
					    setDefaultCoreTranslation(ret, 'fileConsent', '{0} requesting remote file Access. Grant access?');
 | 
				
			||||||
 | 
					    setDefaultCoreTranslation(ret, 'terminalNotify', '{0} started a remote terminal session.');
 | 
				
			||||||
 | 
					    setDefaultCoreTranslation(ret, 'desktopNotify', '{0} started a remote desktop session.');
 | 
				
			||||||
 | 
					    setDefaultCoreTranslation(ret, 'fileNotify', '{0} started a remote file session.');
 | 
				
			||||||
 | 
					    setDefaultCoreTranslation(ret, 'privacyBar', 'Sharing desktop with: {0}');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (ret);
 | 
					    return (ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
var currentTranslation = getCoreTranslation();
 | 
					var currentTranslation = getCoreTranslation();
 | 
				
			||||||
| 
						 | 
					@ -1057,7 +1062,7 @@ function handleServerCommand(data) {
 | 
				
			||||||
                                tunnel.rights = data.rights;
 | 
					                                tunnel.rights = data.rights;
 | 
				
			||||||
                                tunnel.consent = data.consent;
 | 
					                                tunnel.consent = data.consent;
 | 
				
			||||||
                                if (global._MSH && _MSH().LocalConsent != null) { tunnel.consent |= parseInt(_MSH().LocalConsent); }
 | 
					                                if (global._MSH && _MSH().LocalConsent != null) { tunnel.consent |= parseInt(_MSH().LocalConsent); }
 | 
				
			||||||
                                tunnel.privacybartext = data.privacybartext ? data.privacybartext : "Sharing desktop with: {0}";
 | 
					                                tunnel.privacybartext = data.privacybartext ? data.privacybartext : currentTranslation['privacyBar'];
 | 
				
			||||||
                                tunnel.username = data.username + (data.guestname ? (' - ' + data.guestname) : '');
 | 
					                                tunnel.username = data.username + (data.guestname ? (' - ' + data.guestname) : '');
 | 
				
			||||||
                                tunnel.realname = (data.realname ? data.realname : data.username) + (data.guestname ? (' - ' + data.guestname) : '');
 | 
					                                tunnel.realname = (data.realname ? data.realname : data.username) + (data.guestname ? (' - ' + data.guestname) : '');
 | 
				
			||||||
                                tunnel.guestname = data.guestname;
 | 
					                                tunnel.guestname = data.guestname;
 | 
				
			||||||
| 
						 | 
					@ -2274,10 +2279,13 @@ function onTunnelData(data) {
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                // Toast Notification, if required
 | 
					                                // Toast Notification, if required
 | 
				
			||||||
                                if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 2)) {
 | 
					                                if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 2))
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
                                    // User Notifications is required
 | 
					                                    // User Notifications is required
 | 
				
			||||||
                                    var notifyMessage = this.ws.httprequest.username + " started a remote terminal session.", notifyTitle = "MeshCentral";
 | 
					                                    var notifyMessage = currentTranslation['terminalNotify'].replace('{0}', this.ws.httprequest.username);
 | 
				
			||||||
                                    if (this.ws.httprequest.soptions != null) {
 | 
					                                    var notifyTitle = "MeshCentral";
 | 
				
			||||||
 | 
					                                    if (this.ws.httprequest.soptions != null)
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
                                        if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
					                                        if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
				
			||||||
                                        if (this.ws.httprequest.soptions.notifyMsgTerminal != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgTerminal.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
					                                        if (this.ws.httprequest.soptions.notifyMsgTerminal != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgTerminal.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
| 
						 | 
					@ -2506,10 +2514,13 @@ function onTunnelData(data) {
 | 
				
			||||||
                            this.ws._consentpromise = null;
 | 
					                            this.ws._consentpromise = null;
 | 
				
			||||||
                            MeshServerLogEx(30, null, "Starting remote desktop after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
 | 
					                            MeshServerLogEx(30, null, "Starting remote desktop after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
 | 
				
			||||||
                            this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null, msgid: 0 }));
 | 
					                            this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null, msgid: 0 }));
 | 
				
			||||||
                            if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1)) {
 | 
					                            if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1))
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
                                // User Notifications is required
 | 
					                                // User Notifications is required
 | 
				
			||||||
                                var notifyMessage = this.ws.httprequest.realname + " started a remote desktop session.", notifyTitle = "MeshCentral";
 | 
					                                var notifyMessage = currentTranslation['desktopNotify'].replace('{0}', this.ws.httprequest.realname);
 | 
				
			||||||
                                if (this.ws.httprequest.soptions != null) {
 | 
					                                var notifyTitle = "MeshCentral";
 | 
				
			||||||
 | 
					                                if (this.ws.httprequest.soptions != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
                                    if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
					                                    if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
				
			||||||
                                    if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
					                                    if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
| 
						 | 
					@ -2559,7 +2570,8 @@ function onTunnelData(data) {
 | 
				
			||||||
                    if (this.httprequest.consent && (this.httprequest.consent & 1)) {
 | 
					                    if (this.httprequest.consent && (this.httprequest.consent & 1)) {
 | 
				
			||||||
                        // User Notifications is required
 | 
					                        // User Notifications is required
 | 
				
			||||||
                        MeshServerLogEx(35, null, "Started remote desktop with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
 | 
					                        MeshServerLogEx(35, null, "Started remote desktop with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
 | 
				
			||||||
                        var notifyMessage = this.httprequest.realname + " started a remote desktop session.", notifyTitle = "MeshCentral";
 | 
					                        var notifyMessage = currentTranslation['desktopNotify'].replace('{0}', this.ws.httprequest.realname);
 | 
				
			||||||
 | 
					                        var notifyTitle = "MeshCentral";
 | 
				
			||||||
                        if (this.httprequest.soptions != null) {
 | 
					                        if (this.httprequest.soptions != null) {
 | 
				
			||||||
                            if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
 | 
					                            if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
 | 
				
			||||||
                            if (this.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.httprequest.realname).replace('{1}', this.httprequest.username); }
 | 
					                            if (this.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.httprequest.realname).replace('{1}', this.httprequest.username); }
 | 
				
			||||||
| 
						 | 
					@ -2638,7 +2650,8 @@ function onTunnelData(data) {
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Perform notification if needed. Toast messages may not be supported on all platforms.
 | 
					                // Perform notification if needed. Toast messages may not be supported on all platforms.
 | 
				
			||||||
                if (this.httprequest.consent && (this.httprequest.consent & 32)) {
 | 
					                if (this.httprequest.consent && (this.httprequest.consent & 32))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    // User Consent Prompt is required
 | 
					                    // User Consent Prompt is required
 | 
				
			||||||
                    // Send a console message back using the console channel, "\n" is supported.
 | 
					                    // Send a console message back using the console channel, "\n" is supported.
 | 
				
			||||||
                    this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
 | 
					                    this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
 | 
				
			||||||
| 
						 | 
					@ -2700,8 +2713,10 @@ function onTunnelData(data) {
 | 
				
			||||||
                            this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
 | 
					                            this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
 | 
				
			||||||
                            if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
 | 
					                            if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
 | 
				
			||||||
                                // User Notifications is required
 | 
					                                // User Notifications is required
 | 
				
			||||||
                                var notifyMessage = this.ws.httprequest.realname + " started a remote file session.", notifyTitle = "MeshCentral";
 | 
					                                var notifyMessage = currentTranslation['fileNotify'].replace('{0}',  this.ws.httprequest.realname);
 | 
				
			||||||
                                if (this.ws.httprequest.soptions != null) {
 | 
					                                var notifyTitle = "MeshCentral";
 | 
				
			||||||
 | 
					                                if (this.ws.httprequest.soptions != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
                                    if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
					                                    if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
 | 
				
			||||||
                                    if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
					                                    if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
| 
						 | 
					@ -2715,13 +2730,18 @@ function onTunnelData(data) {
 | 
				
			||||||
                            MeshServerLogEx(41, null, "Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
 | 
					                            MeshServerLogEx(41, null, "Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
 | 
				
			||||||
                            this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
 | 
					                            this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
                } else {
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    // User Consent Prompt is not required
 | 
					                    // User Consent Prompt is not required
 | 
				
			||||||
                    if (this.httprequest.consent && (this.httprequest.consent & 4)) {
 | 
					                    if (this.httprequest.consent && (this.httprequest.consent & 4))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
                        // User Notifications is required
 | 
					                        // User Notifications is required
 | 
				
			||||||
                        MeshServerLogEx(42, null, "Started remote files with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
 | 
					                        MeshServerLogEx(42, null, "Started remote files with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
 | 
				
			||||||
                        var notifyMessage = this.httprequest.realname + " started a remote file session.", notifyTitle = "MeshCentral";
 | 
					                        var notifyMessage = currentTranslation['fileNotify'].replace('{0}', this.ws.httprequest.realname);
 | 
				
			||||||
                        if (this.httprequest.soptions != null) {
 | 
					                        var notifyTitle = "MeshCentral";
 | 
				
			||||||
 | 
					                        if (this.httprequest.soptions != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
                            if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
 | 
					                            if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
 | 
				
			||||||
                            if (this.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.httprequest.soptions.notifyMsgFiles.replace('{0}', this.httprequest.realname).replace('{1}', this.httprequest.username); }
 | 
					                            if (this.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.httprequest.soptions.notifyMsgFiles.replace('{0}', this.httprequest.realname).replace('{1}', this.httprequest.username); }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,11 @@
 | 
				
			||||||
    "autoAllowForFive": "Auto accept all connections for next 5 minutes",
 | 
					    "autoAllowForFive": "Auto accept all connections for next 5 minutes",
 | 
				
			||||||
    "terminalConsent": "{0} requesting remote terminal access. Grant access?",
 | 
					    "terminalConsent": "{0} requesting remote terminal access. Grant access?",
 | 
				
			||||||
    "desktopConsent": "{0} requesting remote desktop access. Grant access?",
 | 
					    "desktopConsent": "{0} requesting remote desktop access. Grant access?",
 | 
				
			||||||
    "fileConsent": "{0} requesting remote file Access. Grant access?"
 | 
					    "fileConsent": "{0} requesting remote file Access. Grant access?",
 | 
				
			||||||
 | 
					    "terminalNotify": "{0} started a remote terminal session.",
 | 
				
			||||||
 | 
					    "desktopNotify": "{0} started a remote desktop session.",
 | 
				
			||||||
 | 
					    "fileNotify": "{0} started a remote file session.",
 | 
				
			||||||
 | 
					    "privacyBar":  "Sharing desktop with: {0}"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "cs": {
 | 
					  "cs": {
 | 
				
			||||||
    "allow": "Dovolit",
 | 
					    "allow": "Dovolit",
 | 
				
			||||||
| 
						 | 
					@ -41,7 +45,11 @@
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "ko": {
 | 
					  "ko": {
 | 
				
			||||||
    "allow": "허용하다",
 | 
					    "allow": "허용하다",
 | 
				
			||||||
    "deny": "거부"
 | 
					    "deny": "거부하다",
 | 
				
			||||||
 | 
					    "terminalNotify": "원격 터미널 세션이 시작되었습니다: {0}",
 | 
				
			||||||
 | 
					    "desktopNotify": "원격 데스크톱 세션이 시작되었습니다: {0}",
 | 
				
			||||||
 | 
					    "fileNotify": "원격 파일 전송 세션이 시작되었습니다: {0}",
 | 
				
			||||||
 | 
					    "privacyBar": "다음과 데스크탑 공유: {0}"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "nl": {
 | 
					  "nl": {
 | 
				
			||||||
    "allow": "Toestaan",
 | 
					    "allow": "Toestaan",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue