mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 09:21:04 +00:00
Add frontend translation timeout parameter #29
This commit is contained in:
parent
370ff7a37c
commit
6d5f6bdc6c
3 changed files with 11 additions and 4 deletions
|
@ -13,7 +13,7 @@ def get_remote_address():
|
||||||
|
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en"):
|
def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en", frontend_timeout=500):
|
||||||
from app.init import boot
|
from app.init import boot
|
||||||
boot()
|
boot()
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html', gaId=ga_id)
|
return render_template('index.html', gaId=ga_id, frontendTimeout=frontend_timeout)
|
||||||
|
|
||||||
@app.route("/languages")
|
@app.route("/languages")
|
||||||
def langs():
|
def langs():
|
||||||
|
@ -274,6 +274,9 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa
|
||||||
charLimit:
|
charLimit:
|
||||||
type: integer
|
type: integer
|
||||||
description: Character input limit for this language (-1 indicates no limit)
|
description: Character input limit for this language (-1 indicates no limit)
|
||||||
|
frontendTimeout:
|
||||||
|
type: integer
|
||||||
|
description: Frontend translation timeout
|
||||||
language:
|
language:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -297,6 +300,7 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa
|
||||||
description: Human-readable language name (in English)
|
description: Human-readable language name (in English)
|
||||||
"""
|
"""
|
||||||
return jsonify({'charLimit': char_limit,
|
return jsonify({'charLimit': char_limit,
|
||||||
|
'frontendTimeout': frontend_timeout,
|
||||||
'language': {
|
'language': {
|
||||||
'source': {'code': frontend_argos_language_source.code, 'name': frontend_argos_language_source.name},
|
'source': {'code': frontend_argos_language_source.code, 'name': frontend_argos_language_source.name},
|
||||||
'target': {'code': frontend_argos_language_target.code, 'name': frontend_argos_language_target.name}}
|
'target': {'code': frontend_argos_language_target.code, 'name': frontend_argos_language_target.name}}
|
||||||
|
|
|
@ -441,7 +441,7 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
request.send(data);
|
request.send(data);
|
||||||
}, 300);
|
}, {{ frontendTimeout }});
|
||||||
},
|
},
|
||||||
|
|
||||||
copyText: function(e){
|
copyText: function(e){
|
||||||
|
|
5
main.py
5
main.py
|
@ -22,6 +22,8 @@ parser.add_argument('--frontend-language-source', type=str, default="en", metava
|
||||||
help='Set frontend default language - source (%(default)s)')
|
help='Set frontend default language - source (%(default)s)')
|
||||||
parser.add_argument('--frontend-language-target', type=str, default="es", metavar="<language code>",
|
parser.add_argument('--frontend-language-target', type=str, default="es", metavar="<language code>",
|
||||||
help='Set frontend default language - target (%(default)s)')
|
help='Set frontend default language - target (%(default)s)')
|
||||||
|
parser.add_argument('--frontend-timeout', type=int, default=500, metavar="<milliseconds>",
|
||||||
|
help='Set frontend translation timeout (%(default)s)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -33,7 +35,8 @@ if __name__ == "__main__":
|
||||||
ga_id=args.ga_id,
|
ga_id=args.ga_id,
|
||||||
debug=args.debug,
|
debug=args.debug,
|
||||||
frontend_language_source=args.frontend_language_source,
|
frontend_language_source=args.frontend_language_source,
|
||||||
frontend_language_target=args.frontend_language_target)
|
frontend_language_target=args.frontend_language_target,
|
||||||
|
frontend_timeout=args.frontend_timeout)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
app.run(host=args.host, port=args.port)
|
app.run(host=args.host, port=args.port)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue