mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-29 03:11:01 +00:00
Disable suggestions by default
This commit is contained in:
parent
0561deb1b4
commit
0ff3ca65fb
4 changed files with 19 additions and 5 deletions
|
@ -592,6 +592,7 @@ def create_app(args):
|
||||||
{
|
{
|
||||||
"charLimit": args.char_limit,
|
"charLimit": args.char_limit,
|
||||||
"frontendTimeout": args.frontend_timeout,
|
"frontendTimeout": args.frontend_timeout,
|
||||||
|
"suggestions": args.suggestions,
|
||||||
"language": {
|
"language": {
|
||||||
"source": {
|
"source": {
|
||||||
"code": frontend_argos_language_source.code,
|
"code": frontend_argos_language_source.code,
|
||||||
|
@ -618,6 +619,9 @@ def create_app(args):
|
||||||
@app.route("/suggest", methods=["POST"])
|
@app.route("/suggest", methods=["POST"])
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def suggest():
|
def suggest():
|
||||||
|
if args.suggestions is False:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
q = request.values.get("q")
|
q = request.values.get("q")
|
||||||
s = request.values.get("s")
|
s = request.values.get("s")
|
||||||
source_lang = request.values.get("source")
|
source_lang = request.values.get("source")
|
||||||
|
|
|
@ -110,6 +110,11 @@ _default_options_objects = [
|
||||||
'name': 'LOAD_ONLY',
|
'name': 'LOAD_ONLY',
|
||||||
'default_value': None,
|
'default_value': None,
|
||||||
'value_type': 'str'
|
'value_type': 'str'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'SUGGESTIONS',
|
||||||
|
'default_value': False,
|
||||||
|
'value_type': 'bool'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,9 @@ def main():
|
||||||
metavar="<comma-separated language codes>",
|
metavar="<comma-separated language codes>",
|
||||||
help="Set available languages (ar,de,en,es,fr,ga,hi,it,ja,ko,pt,ru,zh)",
|
help="Set available languages (ar,de,en,es,fr,ga,hi,it,ja,ko,pt,ru,zh)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--suggestions", default=DEFARGS['SUGGESTIONS'], action="store_true", help="Allow user suggestions"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
app = create_app(args)
|
app = create_app(args)
|
||||||
|
|
|
@ -148,15 +148,15 @@
|
||||||
<label for="textarea2" class="sr-only">
|
<label for="textarea2" class="sr-only">
|
||||||
Translated text
|
Translated text
|
||||||
</label>
|
</label>
|
||||||
<textarea id="textarea2" v-model="translatedText" ref="translatedTextarea" dir="auto" v-bind:readonly="!isSuggesting"></textarea>
|
<textarea id="textarea2" v-model="translatedText" ref="translatedTextarea" dir="auto" v-bind:readonly="suggestions && !isSuggesting"></textarea>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button v-if="!loadingTranslation && inputText.length && !isSuggesting" class="btn-action" @click="suggestTranslation">
|
<button v-if="suggestions && !loadingTranslation && inputText.length && !isSuggesting" class="btn-action" @click="suggestTranslation">
|
||||||
<i class="material-icons">edit</i>
|
<i class="material-icons">edit</i>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="!loadingTranslation && inputText.length && isSuggesting" class="btn-action btn-blue" @click="closeSuggestTranslation">
|
<button v-if="suggestions && !loadingTranslation && inputText.length && isSuggesting" class="btn-action btn-blue" @click="closeSuggestTranslation">
|
||||||
<span>Cancel</span>
|
<span>Cancel</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="!loadingTranslation && inputText.length && isSuggesting" :disabled="!canSendSuggestion" class="btn-action btn-blue" @click="sendSuggestion">
|
<button v-if="suggestions && !loadingTranslation && inputText.length && isSuggesting" :disabled="!canSendSuggestion" class="btn-action btn-blue" @click="sendSuggestion">
|
||||||
<span>Send</span>
|
<span>Send</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="!isSuggesting" class="btn-action btn-copy-translated" @click="copyText">
|
<button v-if="!isSuggesting" class="btn-action btn-copy-translated" @click="copyText">
|
||||||
|
@ -279,6 +279,7 @@
|
||||||
|
|
||||||
copyTextLabel: "Copy text",
|
copyTextLabel: "Copy text",
|
||||||
|
|
||||||
|
suggestions: false,
|
||||||
isSuggesting: false,
|
isSuggesting: false,
|
||||||
},
|
},
|
||||||
mounted: function(){
|
mounted: function(){
|
||||||
|
@ -293,7 +294,8 @@
|
||||||
self.sourceLang = self.settings.language.source.code;
|
self.sourceLang = self.settings.language.source.code;
|
||||||
self.targetLang = self.settings.language.target.code;
|
self.targetLang = self.settings.language.target.code;
|
||||||
self.charactersLimit = self.settings.charLimit;
|
self.charactersLimit = self.settings.charLimit;
|
||||||
}else {
|
self.suggestions = self.settings.suggestions;
|
||||||
|
}else {
|
||||||
self.error = "Cannot load /frontend/settings";
|
self.error = "Cannot load /frontend/settings";
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue