1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-11-24 08:02:18 +02:00

Remove --offline flag

This commit is contained in:
Piero Toffanin 2021-05-16 10:42:58 -04:00
parent c7cc9efee7
commit 800774f557
6 changed files with 18 additions and 19 deletions

View File

@ -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` |

View File

@ -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

View File

@ -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:

View File

@ -26,8 +26,6 @@ def main():
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)')
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', ','),

View File

@ -15,11 +15,11 @@
<meta property="og:description" name="description" class="swiftype" content="Free and Open Source Machine Translation API. 100% self-hosted, no limits, no ties to proprietary services. Run your own API server in just a few minutes."/>
<script src="{% if offline %}{{ url_for('static', filename='js/vue@2.js') }}{% else %}https://cdn.jsdelivr.net/npm/vue@2{% endif %}"></script>
<script src="{{ url_for('static', filename='js/vue@2.js') }}"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="{% if offline %}{{ url_for('static', filename='css/materialize.min.css') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css{% endif %}">
<link href="{% if offline %}{{ url_for('static', filename='css/material-icons.css') }}{% else %}https://fonts.googleapis.com/icon?family=Material+Icons{% endif %}" rel="stylesheet">
<link href="{% if offline %}{{ url_for('static', filename='css/prism.min.css') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/themes/prism.min.css{% endif %}" rel="stylesheet" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}">
<link href="{{ url_for('static', filename='css/material-icons.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/prism.min.css') }}" rel="stylesheet" />
<style type="text/css">
textarea.materialize-textarea{height: 120px;}
@ -254,7 +254,7 @@
</div>
</footer>
<script src="{% if offline %}{{ url_for('static', filename='js/materialize.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js{% endif %}"></script>
<script src="{{ url_for('static', filename='js/materialize.min.js') }}"></script>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
window.Prism = window.Prism || {};
@ -262,7 +262,7 @@ window.Prism.manual = true;
// @license-end
</script>
<script src="{% if offline %}{{ url_for('static', filename='js/prism.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/prism.min.js{% endif %}"></script>
<script src="{{ url_for('static', filename='js/prism.min.js') }}"></script>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0

View File

@ -6,15 +6,15 @@
<h3>Weblabels</h3>
<table id="jslicense-labels1" border="1">
<tr>
<td><a href="{% if offline %}{{ url_for('static', filename='js/vue@2.js') }}{% else %}https://cdn.jsdelivr.net/npm/vue@2{% endif %}">Vue.js</a></td>
<td><a href="{{ url_for('static', filename='js/vue@2.js') }}">Vue.js</a></td>
<td><a href="http://www.jclark.com/xml/copying.txt">Expat</a></td>
</tr>
<tr>
<td><a href="{% if offline %}{{ url_for('static', filename='js/prism.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/prism.min.js{% endif %}">prism.min.js</a></td>
<td><a href="{{ url_for('static', filename='js/prism.min.js') }}">prism.min.js</a></td>
<td><a href="http://www.jclark.com/xml/copying.txt">Expat</a></td>
</tr>
<tr>
<td><a href="{% if offline %}{{ url_for('static', filename='js/materialize.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js{% endif %}">materialize.min.js</a></td>
<td><a href="{{ url_for('static', filename='js/materialize.min.js') }}">materialize.min.js</a></td>
<td><a href="http://www.jclark.com/xml/copying.txt">Expat</a></td>
</tr>
</table>