diff --git a/README.md b/README.md index 8ca1ef7..bd89159 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,6 @@ docker-compose up -d --build | --frontend-language-source | Set frontend default language - source | `en` | | --frontend-language-target | Set frontend default language - target | `es` | | --frontend-timeout | Set frontend translation timeout | `500` | -| --offline | Run user-interface entirely offline (don't use internet CDNs) | `false` | | --api-keys | Enable API keys database for per-user rate limits lookup | `Don't use API keys` | | --load-only | Set available languages | `all from argostranslate` | diff --git a/app/app.py b/app/app.py index 96a1c14..2b0466e 100644 --- a/app/app.py +++ b/app/app.py @@ -47,9 +47,8 @@ def get_routes_limits(default_req_limit, api_keys_db): return [limits] def create_app(args): - if not args.offline: - from app.init import boot - boot(args.load_only) + from app.init import boot + boot(args.load_only) from app.language import languages app = Flask(__name__) @@ -100,12 +99,12 @@ def create_app(args): @app.route("/") @limiter.exempt def index(): - return render_template('index.html', gaId=args.ga_id, frontendTimeout=args.frontend_timeout, offline=args.offline, api_keys=args.api_keys, web_version=os.environ.get('LT_WEB') is not None) + return render_template('index.html', gaId=args.ga_id, frontendTimeout=args.frontend_timeout, api_keys=args.api_keys, web_version=os.environ.get('LT_WEB') is not None) @app.route("/javascript-licenses", methods=['GET']) @limiter.exempt def javascript_licenses(): - return render_template('javascript-licenses.html', offline=args.offline) + return render_template('javascript-licenses.html') @app.route("/languages", methods=['GET', 'POST']) @limiter.exempt diff --git a/app/init.py b/app/init.py index 210c5fe..b44c2b2 100644 --- a/app/init.py +++ b/app/init.py @@ -6,8 +6,11 @@ import app.language import polyglot def boot(load_only=None): - check_and_install_models(load_only_lang_codes=load_only) - check_and_install_transliteration() + try: + check_and_install_models(load_only_lang_codes=load_only) + check_and_install_transliteration() + except Exception as e: + print("Cannot update models (normal if you're offline): %s" % str(e)) def check_and_install_models(force=False, load_only_lang_codes=None): if len(package.get_installed_packages()) < 2 or force: diff --git a/app/main.py b/app/main.py index af60e0f..21aadcd 100644 --- a/app/main.py +++ b/app/main.py @@ -26,8 +26,6 @@ def main(): help='Set frontend default language - target (%(default)s)') parser.add_argument('--frontend-timeout', type=int, default=500, metavar="", help='Set frontend translation timeout (%(default)s)') - parser.add_argument('--offline', default=False, action="store_true", - help="Use offline") parser.add_argument('--api-keys', default=False, action="store_true", help="Enable API keys database for per-user rate limits lookup") parser.add_argument('--load-only', type=operator.methodcaller('split', ','), diff --git a/app/templates/index.html b/app/templates/index.html index 163e8f8..5d7f0d2 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -15,11 +15,11 @@ - + - - - + + +