diff options
author | saturneric <[email protected]> | 2024-01-23 10:14:21 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-23 10:14:21 +0000 |
commit | 3ec6373fc40ca5120e0417ffb41a6341272fd952 (patch) | |
tree | 74e6b9722e6a9217a90715c9fd6d564cf82596c1 /src/init.cpp | |
parent | fix: main windows is too small (diff) | |
download | GpgFrontend-3ec6373fc40ca5120e0417ffb41a6341272fd952.tar.gz GpgFrontend-3ec6373fc40ca5120e0417ffb41a6341272fd952.zip |
fix: solve issues at i18n support
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp index f9a1dabd..8e61f4a7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -94,6 +94,9 @@ void InitGlobalBasicalEnv(const GFCxtWPtr &p_ctx, bool gui_mode) { return; } + // init default locale of application + InitLocale(); + // initialize logging system SetDefaultLogLevel(ctx->log_level); InitLoggingSystem(ctx); @@ -120,6 +123,26 @@ void InitGlobalBasicalEnv(const GFCxtWPtr &p_ctx, bool gui_mode) { InitGpgFrontendCore(core_init_args); } +/** + * @brief setup the locale and load the translations + * + */ +void InitLocale() { + // get the instance of the GlobalSettingStation + auto settings = + GpgFrontend::GlobalSettingStation::GetInstance().GetSettings(); + + // read from settings file + auto lang = settings.value("basic/lang").toString(); + GF_UI_LOG_INFO("current system default locale: {}", QLocale().name()); + GF_UI_LOG_INFO("locale settings from config: {}", lang); + + auto target_locale = + lang.trimmed().isEmpty() ? QLocale::system() : QLocale(lang); + GF_UI_LOG_INFO("application's target locale: {}", target_locale.name()); + QLocale::setDefault(target_locale); +} + void ShutdownGlobalBasicalEnv(const GFCxtWPtr &p_ctx) { GFCxtSPtr ctx = p_ctx.lock(); if (ctx == nullptr) { |