Skip to content

Commit c666a0a

Browse files
committed
Allow setting JVM locale
1 parent 2be5d4b commit c666a0a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

schemas/qwc-document-service.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
"type": "string",
4343
"default": "1024M"
4444
},
45+
"locale": {
46+
"description": "The JVM locale, as a `<lang>_<COUNTRY>` string.",
47+
"type": "string",
48+
"default": "en_US"
49+
},
4550
"virtualizer": {
4651
"title": "JRSwapFileVirtualizer",
4752
"description": "If configuration is set, a JRSwapFileVirtualizer is used for report generation.",

src/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,18 @@ def get_document_worker(config, permitted_resources, tenant, template, args, for
7878
classpath = glob.glob(os.path.join(libdir, '*.jar'))
7979
classpath.append(libdir)
8080

81+
locale = config.get('locale', 'en_US')
82+
lang, country = locale.split("_")
8183
max_memory = config.get('max_memory', '1024M')
8284
app.logger.info("The maximum Java heap size is set to '%s'", max_memory)
8385

8486
tmpdir = tempfile.mkdtemp()
85-
jpype.startJVM("-DJava.awt.headless=true", "-Xmx" + max_memory, "-Djava.util.logging.config.file=" + os.path.join(libdir, "logging.properties"), classpath=classpath)
87+
jpype.startJVM(f"-DJava.awt.headless=true", f"-Xmx{max_memory}", "-Djava.util.logging.config.file=" + os.path.join(libdir, "logging.properties"), classpath=classpath)
8688
jpype.java.lang.System.setOut(jpype.java.io.PrintStream(jpype.java.io.File(os.path.join(tmpdir, "stdout"))))
8789
jpype.java.lang.System.setErr(jpype.java.io.PrintStream(jpype.java.io.File(os.path.join(tmpdir, "stderr"))))
90+
Locale = jpype.java.util.Locale
91+
Locale.setDefault(Locale(lang, country));
92+
app.logger.debug("JVM locale: %s" % Locale.getDefault())
8893

8994
report_compiler = ReportCompiler(app.logger)
9095
result = report_compiler.get_document(config, permitted_resources, tenant, template, dict(request.args), format)

0 commit comments

Comments
 (0)