Spaces:
Running
Running
Update server/babel.py
Browse files- server/babel.py +12 -19
server/babel.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import stat
|
3 |
import subprocess
|
4 |
from flask import request, session, jsonify
|
5 |
from flask_babel import Babel
|
@@ -35,21 +34,15 @@ def get_languages():
|
|
35 |
return jsonify(BABEL_LANGUAGES)
|
36 |
|
37 |
|
38 |
-
def compile_translations():
|
39 |
-
"""Compile the translation files."""
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
)
|
50 |
-
|
51 |
-
if result.returncode != 0:
|
52 |
-
raise Exception(
|
53 |
-
f'Compiling translations failed:\n{result.stdout.decode()}')
|
54 |
-
|
55 |
-
print('Translations compiled successfully')
|
|
|
1 |
import os
|
|
|
2 |
import subprocess
|
3 |
from flask import request, session, jsonify
|
4 |
from flask_babel import Babel
|
|
|
34 |
return jsonify(BABEL_LANGUAGES)
|
35 |
|
36 |
|
37 |
+
def compile_translations():
|
38 |
+
"""Compile the translation files."""
|
39 |
+
result = subprocess.run(
|
40 |
+
['pybabel', 'compile', '-d', 'translations'],
|
41 |
+
stdout=subprocess.PIPE,
|
42 |
+
)
|
43 |
+
|
44 |
+
if result.returncode != 0:
|
45 |
+
raise Exception(
|
46 |
+
f'Compiling translations failed:\n{result.stdout.decode()}')
|
47 |
+
|
48 |
+
print('Translations compiled successfully')
|
|
|
|
|
|
|
|
|
|
|
|