From 4141f48cd70c12f688d1dbecd6334a979800843c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Thu, 5 Jan 2023 22:02:51 +0100 Subject: [PATCH] misc: add make_translation command (#72667) --- .gitignore | 1 + setup.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index 2830888..1baebd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +**/django.mo *.pyc *.egg-info .pytest_cache/ diff --git a/setup.py b/setup.py index 2871a66..916012f 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,31 @@ def get_version(): return '0.0' +class make_translations(Command): + description = 'make message catalogs via django makemessages' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + try: + from django.core.management import call_command + + for path, dirs, files in os.walk('publik_django_templatetags'): + if 'locale' not in dirs: + continue + curdir = os.getcwd() + os.chdir(os.path.realpath(path)) + call_command('makemessages', '-l', 'fr', '--add-location', 'file', '--no-obsolete') + os.chdir(curdir) + except ImportError: + sys.stderr.write('!!! Please install Django >= 2.2 to make translations\n') + + class compile_translations(Command): description = 'compile message catalogs to MO files via django compilemessages' user_options = [] @@ -107,6 +132,7 @@ setup( zip_safe=False, cmdclass={ 'build': build, + 'make_translations': make_translations, 'compile_translations': compile_translations, 'install_lib': install_lib, 'sdist': eo_sdist,