mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-06-26 02:51:05 +00:00
Only show target languages, check swap, bump version
This commit is contained in:
parent
0875fdc433
commit
2b0074b94f
4 changed files with 22 additions and 3 deletions
|
@ -143,6 +143,14 @@ document.addEventListener('DOMContentLoaded', function(){
|
|||
},
|
||||
canSendSuggestion: function(){
|
||||
return this.translatedText.trim() !== "" && this.translatedText !== this.savedTanslatedText;
|
||||
},
|
||||
targetLangs: function(){
|
||||
if (!this.sourceLang) return this.langs;
|
||||
else{
|
||||
var lang = this.langs.find(l => l.code === this.sourceLang);
|
||||
if (!lang) return this.langs;
|
||||
return lang.targets.map(t => this.langs.find(l => l.code === t));
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
|
@ -161,7 +169,13 @@ document.addEventListener('DOMContentLoaded', function(){
|
|||
}
|
||||
},
|
||||
swapLangs: function(e){
|
||||
this.closeSuggestTranslation(e)
|
||||
this.closeSuggestTranslation(e);
|
||||
|
||||
// Make sure that we can swap
|
||||
// by checking that the current target language
|
||||
// has source language as target
|
||||
var tgtLang = this.langs.find(l => l.code === this.targetLang);
|
||||
if (tgtLang.targets.indexOf(this.sourceLang) === -1) return; // Not supported
|
||||
|
||||
var t = this.sourceLang;
|
||||
this.sourceLang = this.targetLang;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue