Translated index.html

This commit is contained in:
Piero Toffanin 2023-01-04 17:54:07 -05:00
parent 3cbbd8ae16
commit 19c3c04ca6
7 changed files with 144 additions and 129 deletions

View file

@ -19,7 +19,7 @@ from flask_babel import Babel, gettext as _
from libretranslate import flood, remove_translated_files, security
from libretranslate.language import detect_languages, improve_translation_formatting
from libretranslate.locales import get_available_locales
from libretranslate.locales import get_available_locales, gettext_escaped, gettext_html
from .api_keys import Database, RemoteDatabase
from .suggestions import Database as SuggestionsDatabase
@ -288,14 +288,6 @@ def create_app(args):
url_prefix=args.url_prefix
)
@bp.get("/javascript-licenses")
@limiter.exempt
def javascript_licenses():
if args.disable_web_ui:
abort(404)
return render_template("javascript-licenses.html")
@bp.route("/static/js/app.js")
@limiter.exempt
def appjs():
@ -1017,15 +1009,16 @@ def create_app(args):
def spec():
return jsonify(swag)
app.config["BABEL_TRANSLATION_DIRECTORIES"] = 'locales'
babel = Babel(app)
@babel.localeselector
def get_locale():
# TODO: populate from available locales
return request.accept_languages.best_match(get_available_locales())
def gettext_escaped(*args, **kwargs):
return _(*args, **kwargs).replace("'", "\\'")
app.jinja_env.globals.update(N_=gettext_escaped)
app.jinja_env.globals.update(_e=gettext_escaped, _h=gettext_html)
# Call factory function to create our blueprint
swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)