From b90d9969655294c4af9efc9cd815aa45bf5fcad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=20=7C=20Anton=20R=C3=B6hm?= <18481195+AnTheMaker@users.noreply.github.com> Date: Sat, 1 Oct 2022 14:21:50 +0200 Subject: [PATCH 1/2] introduce detectedLangText var to store auto-detected lang --- app/static/js/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/static/js/app.js b/app/static/js/app.js index 6605f8e..4e25f57 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -25,6 +25,8 @@ document.addEventListener('DOMContentLoaded', function(){ translatedText: "", output: "", charactersLimit: -1, + + detectedLangText: "", copyTextLabel: "Copy text", @@ -189,6 +191,8 @@ document.addEventListener('DOMContentLoaded', function(){ if (this.timeout) clearTimeout(this.timeout); this.timeout = null; + this.detectedLangText = ""; + if (this.inputText === ""){ this.translatedText = ""; this.output = ""; @@ -223,6 +227,9 @@ document.addEventListener('DOMContentLoaded', function(){ self.translatedText = res.translatedText; self.loadingTranslation = false; self.output = JSON.stringify(res, null, 4); + if(self.sourceLang == "auto" && res.detectedLanguage.length > 0){ + self.detectedLangText = res.detectedLanguage.language+" ("+res.detectedLanguage.confidence+"%)"; + } } else{ throw new Error(res.error || "Unknown error"); } From 99b6a1a2f2a418d73327107df41a33d1b7dbb03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=20=7C=20Anton=20R=C3=B6hm?= <18481195+AnTheMaker@users.noreply.github.com> Date: Sat, 1 Oct 2022 14:25:29 +0200 Subject: [PATCH 2/2] Show detectedLangText --- app/templates/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/index.html b/app/templates/index.html index 912997b..454c49f 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -142,6 +142,7 @@