mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-10-30 22:59:52 +01:00 
			
		
		
		
	Compile Javascript translations in STATIC_ROOT directory
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay | # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay | ||||||
| # SPDX-License-Identifier: GPL-3.0-or-later | # SPDX-License-Identifier: GPL-3.0-or-later | ||||||
|  |  | ||||||
| import os | import os | ||||||
|  |  | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| @@ -12,9 +13,6 @@ class Command(BaseCommand): | |||||||
|     """ |     """ | ||||||
|     Generate Javascript translation files |     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): |     def handle(self, *args, **kwargs): | ||||||
|         for code, _ in settings.LANGUAGES: |         for code, _ in settings.LANGUAGES: | ||||||
|             if code == settings.LANGUAGE_CODE: |             if code == settings.LANGUAGE_CODE: | ||||||
| @@ -23,7 +21,7 @@ class Command(BaseCommand): | |||||||
|                 self.stdout.write(f"Generate {code} javascript localization file") |                 self.stdout.write(f"Generate {code} javascript localization file") | ||||||
|             with translation.override(code): |             with translation.override(code): | ||||||
|                 resp = JavaScriptCatalog().get(None, packages="member+note") |                 resp = JavaScriptCatalog().get(None, packages="member+note") | ||||||
|                 if not os.path.isdir(kwargs["out"] + "/js/jsi18n"): |                 if not os.path.isdir(settings.STATIC_ROOT + "/js/jsi18n"): | ||||||
|                     os.makedirs(kwargs["out"] + "/js/jsi18n") |                     os.makedirs(settings.STATIC_ROOT + "/js/jsi18n") | ||||||
|                 with open(kwargs["out"] + f"/js/jsi18n/{code}.js", "wb") as f: |                 with open(settings.STATIC_ROOT + f"/js/jsi18n/{code}.js", "wb") as f: | ||||||
|                     f.write(resp.content) |                     f.write(resp.content) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user