mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-08-21 22:00:15 +02:00
show iso if language name is not found (prevent error)
This commit is contained in:
parent
3072219085
commit
eee2cf2f33
@ -228,7 +228,8 @@ document.addEventListener('DOMContentLoaded', function(){
|
|||||||
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 !== undefined){
|
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{
|
} else{
|
||||||
throw new Error(res.error || "Unknown error");
|
throw new Error(res.error || "Unknown error");
|
||||||
|
Loading…
Reference in New Issue
Block a user