added &ln=auto as an option, etc

This commit is contained in:
steveseguin
2024-03-28 13:55:56 -04:00
parent ae19ce9564
commit 4a5f7690cd
4 changed files with 38 additions and 14 deletions

View File

@@ -24,7 +24,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta content="utf-8" http-equiv="encoding" />
<meta name="copyright" content="&copy; 2023 Steve Seguin" />
<meta name="copyright" content="&copy; 2024 Steve Seguin" />
<meta name="license" content="https://github.com/steveseguin/vdo.ninja/LICENSE.md" />
<meta name="sourcecode" content="https://github.com/steveseguin/vdo.ninja" />
<meta name="stance-on-war" content="Steve Seguin condemns Russia's brutal invasion of Ukraine 💙💛." />
@@ -92,7 +92,7 @@
<script type="text/javascript" crossorigin="anonymous" src="./thirdparty/CodecsHandler.js?ver=10"></script>
<script type="text/javascript" crossorigin="anonymous" src="./thirdparty/aes.js"></script>
<script type="text/javascript" crossorigin="anonymous" src="./webrtc.js?ver=779"></script>
<script type="text/javascript" crossorigin="anonymous" src="./webrtc.js?ver=780"></script>
<input id="zoomSlider" type="range" style="display: none;" />
<span id="electronDragZone" style="pointer-events: none; z-index:-10; position:absolute;top:0;left:0;width:100%;height:2%;-webkit-app-region: drag;min-height:20px;"></span>
<div id="header">
@@ -2695,6 +2695,7 @@
// session.darkmode = false; // enable or disable the dark style theme as the default
// session.defaultBackgroundImages = ["./media/bg_sample1.webp", "./media/bg_sample2.webp"]; // for &effects=5 (virtual backgrounds)
// session.hidehome = true; // If used, 'hide home' will make the landing page inaccessible, along with hiding a few go-home elements.
// session.language="auto"; // "blank" is another option, or a specific language, like "de" or "pt-br"
// session.record = false; // uncomment to block users from being able to record via vdo.ninja's built in recording function
// session.whipServerURL = "wss://whip.vdo.ninja"; // If you deploy your own whip websocket service
@@ -2704,11 +2705,7 @@
// session.decrypted = session.decodeInvite("U2FsdGVkX1+d58DFIHoO3EQZSuX86ch4PqW2ouztnJ0="); // get a code from invite.cam
</script>
<script type="text/javascript" crossorigin="anonymous" id="lib-js" src="./lib.js?ver=1136"></script>
<!--
// If you wish to change branding, blank offers a good clean start.
<script type="text/javascript" id="main-js" src="./main.js" data-translation="blank"></script>
-->
<script type="text/javascript" crossorigin="anonymous" id="main-js" src="./main.js?ver=842"></script>
<script type="text/javascript" crossorigin="anonymous" id="lib-js" src="./lib.js?ver=1137"></script>
<script type="text/javascript" crossorigin="anonymous" id="main-js" src="./main.js?ver=844"></script>
</body>
</html>

32
lib.js
View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Steve Seguin. All Rights Reserved.
* Copyright (c) 2024 Steve Seguin. All Rights Reserved.
*
* Use of this source code is governed by the APGLv3 open-source license
* that can be found in the LICENSE file in the root of the source
@@ -6657,6 +6657,14 @@ function showControl(e){
async function changeLg(lang) {
log("changeLg: "+lang);
var retry = false;
if (lang == "auto"){
const navlang = navigator.language || navigator.userLanguage || "";
const userLang = navlang.toLowerCase(); // Convert to lower case
lang = userLang.replace('_', '-'); // Replace dash with underscore if present
retry = true;
}
await fetchWithTimeout("./translations/" + lang + '.json',2000).then(async function(response) {
try{
if (response.status !== 200) {
@@ -6718,12 +6726,30 @@ async function changeLg(lang) {
getById("mainmenu").style.opacity = 1;
}).catch(async function(err2) {
if (retry){
console.warn("Couldn't find the exact language file for '"+lang+"'; trying a more generic option instead");
lang = lang.split('-')[0];
if (lang && (lang!=="auto")){
await changeLg(lang); // won't retry I'd hope.
}
} else {
errorlog(err2);
}
});
} catch(e){
getById("mainmenu").style.opacity = 1;
}
}).catch(function(err) {
errorlog(err);
}).catch(async function(err) {
if (retry){
console.warn("Couldn't find exact language; trying a more generic option instead");
lang = lang.split('-')[0];
if (lang && (lang!=="auto")){
await changeLg(lang); // won't retry I'd hope.
}
} else {
errorlog(err);
}
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Steve Seguin. All Rights Reserved.
* Copyright (c) 2024 Steve Seguin. All Rights Reserved.
*
* Use of this source code is governed by the APGLv3 open-source license
* that can be found in the LICENSE file in the root of the source
@@ -13,7 +13,6 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
// translation stuff start ////
var ConfigSettings = getById("main-js");
var ln_template = false;
try {
if (ConfigSettings) {
@@ -27,6 +26,8 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
if (urlParams.has('ln') || urlParams.has('language')) {
ln_template = urlParams.get('ln') || urlParams.get('language') || null;
} else if (session.language){
ln_template = session.language;
}
} catch (e) {
errorlog(e);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Steve Seguin. All Rights Reserved.
* Copyright (c) 2024 Steve Seguin. All Rights Reserved.
*
* This file is part of VDO.Ninja, yet is not intended to be modified.
* This file cannot be modified without the express permission of its author.