From fc56fdade75610fabf42426cdc8960b9f1ba77a4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 2 Jan 2024 16:49:40 +0800 Subject: [PATCH] Specify a locale if none is set Sometimes users had not properly configured their system locale and thus qbt will specify a default locale just in case. Closes #16127. Closes #19609. Closes #19834. PR #20203. --- src/app/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/main.cpp b/src/app/main.cpp index ff79eb258..53455f99b 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -163,6 +163,14 @@ namespace limit.rlim_cur = limit.rlim_max; setrlimit(RLIMIT_NOFILE, &limit); } + + void adjustLocale() + { + // specify the default locale just in case if user has not set any other locale + // only `C` locale is available universally without installing locale packages + if (qEnvironmentVariableIsEmpty("LANG")) + qputenv("LANG", "C.UTF-8"); + } #endif } @@ -174,6 +182,7 @@ int main(int argc, char *argv[]) #endif #ifdef Q_OS_UNIX + adjustLocale(); adjustFileDescriptorLimit(); #endif