From eee2cf2f33f4d5c7f44502563e19cb2147d7d3d1 Mon Sep 17 00:00:00 2001 From: dingedi Date: Sun, 2 Oct 2022 14:20:20 +0200 Subject: [PATCH] show iso if language name is not found (prevent error) --- app/static/js/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/static/js/app.js b/app/static/js/app.js index e5974ea..d1e9157 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -228,7 +228,8 @@ document.addEventListener('DOMContentLoaded', function(){ self.loadingTranslation = false; self.output = JSON.stringify(res, null, 4); if(self.sourceLang == "auto" && res.detectedLanguage !== undefined){ - self.detectedLangText = ": " + self.langs.find(l => l.code === res.detectedLanguage.language).name+" ("+res.detectedLanguage.confidence+"%)"; + let lang = self.langs.find(l => l.code === res.detectedLanguage.language) + self.detectedLangText = ": " + (lang !== undefined ? lang.name : res.detectedLanguage.language) + " (" + res.detectedLanguage.confidence + "%)"; } } else{ throw new Error(res.error || "Unknown error");