From 1cf23bdc051bf48b1533423c0a1399d23fcf91ae Mon Sep 17 00:00:00 2001 From: Stephen Sorriaux Date: Sun, 28 Mar 2021 17:26:31 -0400 Subject: [PATCH] Fix `languages` reload As this object can be updated from outside its own module, the module should be imported and used instead. Relates to https://github.com/uav4geo/LibreTranslate/issues/54 --- app/init.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/init.py b/app/init.py index 4724738..210c5fe 100644 --- a/app/init.py +++ b/app/init.py @@ -2,7 +2,7 @@ import os from pathlib import Path from argostranslate import settings, package, translate import os, glob, shutil, zipfile -from app.language import languages +import app.language import polyglot def boot(load_only=None): @@ -45,14 +45,13 @@ def check_and_install_models(force=False, load_only_lang_codes=None): package.install_from_path(download_path) # reload installed languages - global languages - languages = translate.load_installed_languages() + app.language.languages = translate.load_installed_languages() print("Loaded support for %s languages (%s models total)!" % (len(translate.load_installed_languages()), len(available_packages))) def check_and_install_transliteration(force=False): # 'en' is not a supported transliteration language - transliteration_languages = [l.code for l in languages if l.code != "en"] + transliteration_languages = [l.code for l in app.language.languages if l.code != "en"] # check installed install_needed = []