better display of detected language

This commit is contained in:
dingedi 2022-10-01 17:34:17 +02:00
parent 5d8e513d45
commit 3072219085
No known key found for this signature in database
GPG key ID: EE23A12D271A3CED
2 changed files with 2 additions and 2 deletions

View file

@ -228,7 +228,7 @@ document.addEventListener('DOMContentLoaded', function(){
self.loadingTranslation = false;
self.output = JSON.stringify(res, null, 4);
if(self.sourceLang == "auto" && res.detectedLanguage !== undefined){
self.detectedLangText = res.detectedLanguage.language+" ("+res.detectedLanguage.confidence+"%)";
self.detectedLangText = ": " + self.langs.find(l => l.code === res.detectedLanguage.language).name+" ("+res.detectedLanguage.confidence+"%)";
}
} else{
throw new Error(res.error || "Unknown error");

View file

@ -142,7 +142,7 @@
<div class="row mb-0">
<div class="col s6 language-select">
<span>Translate from</span>
<span><i>[[ detectedLangText ]]</i></span>
<span v-if="detectedLangText !== ''">[[ detectedLangText ]]</span>
<select class="browser-default" v-model="sourceLang" ref="sourceLangDropdown" @change="handleInput">
<template v-for="option in langs">
<option :value="option.code">[[ option.name ]]</option>