setup: use django's command caller for translations compilation (#78765)
gitea/eopayment/pipeline/head This commit looks good
Details
gitea/eopayment/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a193f26291
commit
7c0d198ba7
19
setup.py
19
setup.py
|
@ -10,9 +10,9 @@ import doctest
|
|||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from distutils.cmd import Command
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.spawn import find_executable
|
||||
from glob import glob
|
||||
from os.path import basename
|
||||
from os.path import join as pjoin
|
||||
|
@ -106,10 +106,19 @@ class compile_translations(Command):
|
|||
pass
|
||||
|
||||
def run(self):
|
||||
django_admin = find_executable('django-admin')
|
||||
if django_admin:
|
||||
os.environ.pop('DJANGO_SETTINGS_MODULE', None)
|
||||
subprocess.check_call([django_admin, 'compilemessages'])
|
||||
curdir = os.getcwd()
|
||||
try:
|
||||
from django.core.management import call_command
|
||||
|
||||
for path, dirs, files in os.walk('eopayment'):
|
||||
if 'locale' not in dirs:
|
||||
continue
|
||||
os.chdir(os.path.realpath(path))
|
||||
call_command('compilemessages')
|
||||
except ImportError:
|
||||
sys.stderr.write('!!! Please install Django >= 3.2 to build translations\n')
|
||||
finally:
|
||||
os.chdir(curdir)
|
||||
|
||||
|
||||
class build(_build):
|
||||
|
|
Loading…
Reference in New Issue