Merge pull request #954 from pierotofy/fixreloadlocale

Fixed locale reload
pull/955/head
Piero Toffanin 2021-01-12 10:40:02 -05:00 zatwierdzone przez GitHub
commit 80b62bca52
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 24 dodań i 11 usunięć

Wyświetl plik

@ -9,7 +9,7 @@ from webodm import settings
from django.http import JsonResponse
from django.utils.translation import get_language
import requests
import json, tempfile, os, logging, shutil, subprocess, zipfile, glob
import json, tempfile, os, logging, shutil, subprocess, zipfile, glob, pathlib
logger = logging.getLogger('app.logger')
@ -20,6 +20,17 @@ def download_file(url, destination):
for chunk in download_stream.iter_content(4096):
fd.write(chunk)
def copymerge(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
pathlib.Path(d).mkdir(parents=True, exist_ok=True)
copymerge(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
@user_passes_test(lambda u: u.is_superuser)
def dev_tools(request, action):
if not settings.DEV:
@ -43,20 +54,19 @@ def dev_tools(request, action):
zip.extractall(path=tmpPath)
os.unlink(tmpzipPath)
locale_path = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
if len(locale_path) != 1:
locale_paths = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
if len(locale_paths) == 0:
raise Exception(_("Cannot find locale/ folder in .zip archive"))
locale_path = locale_path[0]
logger.info("Found locale at %s" % locale_path)
webodm_locale_dir = os.path.join(settings.BASE_DIR, "locale")
if os.path.isdir(webodm_locale_dir):
logger.info("Removing %s" % webodm_locale_dir)
shutil.rmtree(webodm_locale_dir)
logger.info("Removing %s" % webodm_locale_dir)
shutil.rmtree(webodm_locale_dir)
logger.info("Moving %s to %s..." % (locale_path, os.path.join(settings.BASE_DIR, "locale")))
shutil.move(locale_path, settings.BASE_DIR)
for locale_path in locale_paths:
logger.info("Found locale at %s" % locale_path)
logger.info("Moving %s to %s..." % (locale_path, webodm_locale_dir))
copymerge(locale_path, webodm_locale_dir)
logger.info("Running translate.sh extract && translate.sh build safe")
translate_script = os.path.join(settings.BASE_DIR, 'translate.sh')

Wyświetl plik

@ -50,6 +50,9 @@ if [ "$1" = "--setup-devenv" ] || [ "$2" = "--setup-devenv" ]; then
echo Setup pip requirements...
pip install -r requirements.txt
echo Build translations...
./translate.sh build safe
echo Setup webpack watch...
webpack --watch &
fi