From 961365656c3cc20678cf9e2da0fef54bfad9242e Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 22 Apr 2021 16:20:24 +0200 Subject: [PATCH] Compile Javascript translations in STATIC_ROOT directory Signed-off-by: Yohann D'ANELLO --- management/commands/compilejsmessages.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/management/commands/compilejsmessages.py b/management/commands/compilejsmessages.py index c66686a..6348d78 100644 --- a/management/commands/compilejsmessages.py +++ b/management/commands/compilejsmessages.py @@ -1,5 +1,6 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later + import os from django.conf import settings @@ -12,9 +13,6 @@ class Command(BaseCommand): """ Generate Javascript translation files """ - def add_arguments(self, parser): - parser.add_argument('--out', '-o', type=str, default='static', help='Output directory, where static files are.') - def handle(self, *args, **kwargs): for code, _ in settings.LANGUAGES: if code == settings.LANGUAGE_CODE: @@ -23,7 +21,7 @@ class Command(BaseCommand): self.stdout.write(f"Generate {code} javascript localization file") with translation.override(code): resp = JavaScriptCatalog().get(None, packages="member+note") - if not os.path.isdir(kwargs["out"] + "/js/jsi18n"): - os.makedirs(kwargs["out"] + "/js/jsi18n") - with open(kwargs["out"] + f"/js/jsi18n/{code}.js", "wb") as f: + if not os.path.isdir(settings.STATIC_ROOT + "/js/jsi18n"): + os.makedirs(settings.STATIC_ROOT + "/js/jsi18n") + with open(settings.STATIC_ROOT + f"/js/jsi18n/{code}.js", "wb") as f: f.write(resp.content)