mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 17:31:00 +00:00
Merge pull request #323 from AnTheMaker/patch-1
Show detected Language (#314)
This commit is contained in:
commit
7c37681afc
2 changed files with 8 additions and 0 deletions
|
@ -26,6 +26,8 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||||
output: "",
|
output: "",
|
||||||
charactersLimit: -1,
|
charactersLimit: -1,
|
||||||
|
|
||||||
|
detectedLangText: "",
|
||||||
|
|
||||||
copyTextLabel: "Copy text",
|
copyTextLabel: "Copy text",
|
||||||
|
|
||||||
suggestions: false,
|
suggestions: false,
|
||||||
|
@ -189,6 +191,8 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||||
if (this.timeout) clearTimeout(this.timeout);
|
if (this.timeout) clearTimeout(this.timeout);
|
||||||
this.timeout = null;
|
this.timeout = null;
|
||||||
|
|
||||||
|
this.detectedLangText = "";
|
||||||
|
|
||||||
if (this.inputText === ""){
|
if (this.inputText === ""){
|
||||||
this.translatedText = "";
|
this.translatedText = "";
|
||||||
this.output = "";
|
this.output = "";
|
||||||
|
@ -223,6 +227,9 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||||
self.translatedText = res.translatedText;
|
self.translatedText = res.translatedText;
|
||||||
self.loadingTranslation = false;
|
self.loadingTranslation = false;
|
||||||
self.output = JSON.stringify(res, null, 4);
|
self.output = JSON.stringify(res, null, 4);
|
||||||
|
if(self.sourceLang == "auto" && res.detectedLanguage.length > 0){
|
||||||
|
self.detectedLangText = res.detectedLanguage.language+" ("+res.detectedLanguage.confidence+"%)";
|
||||||
|
}
|
||||||
} else{
|
} else{
|
||||||
throw new Error(res.error || "Unknown error");
|
throw new Error(res.error || "Unknown error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@
|
||||||
<div class="row mb-0">
|
<div class="row mb-0">
|
||||||
<div class="col s6 language-select">
|
<div class="col s6 language-select">
|
||||||
<span>Translate from</span>
|
<span>Translate from</span>
|
||||||
|
<span><i>[[ detectedLangText ]]</i></span>
|
||||||
<select class="browser-default" v-model="sourceLang" ref="sourceLangDropdown" @change="handleInput">
|
<select class="browser-default" v-model="sourceLang" ref="sourceLangDropdown" @change="handleInput">
|
||||||
<template v-for="option in langs">
|
<template v-for="option in langs">
|
||||||
<option :value="option.code">[[ option.name ]]</option>
|
<option :value="option.code">[[ option.name ]]</option>
|
||||||
|
|
Loading…
Reference in a new issue