From eb1ab81c575c42cefdc6f66e1e467d0d9b71b86b Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sun, 26 Jan 2025 17:12:03 +0100 Subject: [PATCH] [mirotalk] - make the room language configurable from your config.js --- app/src/config.template.js | 1 + app/src/server.js | 2 +- package.json | 2 +- public/js/brand.js | 1 + public/js/client.js | 4 ++-- public/js/common.js | 18 +++++++++--------- public/js/translate.js | 20 +++++++++++++++++++- public/views/client.html | 1 + public/views/landing.html | 2 +- 9 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/src/config.template.js b/app/src/config.template.js index 1ad1386a..31a811e5 100644 --- a/app/src/config.template.js +++ b/app/src/config.template.js @@ -4,6 +4,7 @@ module.exports = { // Branding and customizations require a license: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 brand: { app: { + language: 'en', name: 'MiroTalk', title: 'MiroTalk
Free browser based Real-time video calls.
Simple, Secure, Fast.', description: diff --git a/app/src/server.js b/app/src/server.js index f4c46fd7..57d403e3 100755 --- a/app/src/server.js +++ b/app/src/server.js @@ -39,7 +39,7 @@ dependencies: { * @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.4.64 + * @version 1.4.65 * */ diff --git a/package.json b/package.json index 09ff8969..077fef12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalk", - "version": "1.4.64", + "version": "1.4.65", "description": "A free WebRTC browser-based video call", "main": "server.js", "scripts": { diff --git a/public/js/brand.js b/public/js/brand.js index 3a75accc..ac280886 100644 --- a/public/js/brand.js +++ b/public/js/brand.js @@ -37,6 +37,7 @@ const footer = document.getElementById('footer'); let brand = { app: { + language: 'en', name: 'MiroTalk', title: 'MiroTalk
Free browser based Real-time video calls.
Simple, Secure, Fast.', description: diff --git a/public/js/client.js b/public/js/client.js index 4eb353cf..2fb55207 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -15,7 +15,7 @@ * @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.4.64 + * @version 1.4.65 * */ @@ -11039,7 +11039,7 @@ function showAbout() { Swal.fire({ background: swBg, position: 'center', - title: 'WebRTC P2P v1.4.64', + title: 'WebRTC P2P v1.4.65', imageAlt: 'mirotalk-about', imageUrl: images.about, customClass: { image: 'img-about' }, diff --git a/public/js/common.js b/public/js/common.js index 6d35ff00..3c496bd5 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -165,6 +165,13 @@ const roomName = document.getElementById('roomName'); if (roomName) { roomName.value = ''; typeWriter(); + + roomName.onkeyup = (e) => { + if (e.keyCode === 13) { + e.preventDefault(); + joinRoom(); + } + }; } // #################################################################### @@ -202,15 +209,8 @@ if (adultCnt) { }; } -document.getElementById('roomName').onkeyup = (e) => { - if (e.keyCode === 13) { - e.preventDefault(); - joinRoom(); - } -}; - function genRoom() { - document.getElementById('roomName').value = getUUID4(); + roomName.value = getUUID4(); } function getUUID4() { @@ -220,7 +220,7 @@ function getUUID4() { } function joinRoom() { - const roomName = filterXSS(document.getElementById('roomName').value).trim().replace(/\s+/g, '-'); + const roomName = filterXSS(roomName.value).trim().replace(/\s+/g, '-'); const roomValid = isValidRoomName(roomName); if (!roomName) { diff --git a/public/js/translate.js b/public/js/translate.js index 966e676b..87192ab3 100644 --- a/public/js/translate.js +++ b/public/js/translate.js @@ -10,5 +10,23 @@ document.head.appendChild(script); * https://www.w3schools.com/howto/howto_google_translate.asp */ function googleTranslateElementInit() { - new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element'); + new google.translate.TranslateElement({ + pageLanguage: 'en', + autoDisplay: false // Prevent the popup from showing by default + }, 'google_translate_element'); + + const interval = setInterval(() => { + const language = brand.app.language ? brand.app.language : 'en'; + + if (language === 'en') { + clearInterval(interval); + } + + const select = document.querySelector('.goog-te-combo'); + if (select) { + select.value = language; + select.dispatchEvent(new Event('change')); + clearInterval(interval); + } + }, 500); } diff --git a/public/views/client.html b/public/views/client.html index af4c19c2..02b33b31 100755 --- a/public/views/client.html +++ b/public/views/client.html @@ -1162,6 +1162,7 @@ access to use this app. + diff --git a/public/views/landing.html b/public/views/landing.html index 626c1c57..42aa6cb8 100755 --- a/public/views/landing.html +++ b/public/views/landing.html @@ -751,9 +751,9 @@ + -