diff options
author | Saturneric <[email protected]> | 2021-12-02 22:44:09 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-12-04 19:28:28 +0000 |
commit | ea7c0113486f336f3fe14435e1ce5eb55ad4eca9 (patch) | |
tree | 8f1c5c61be4d55df5e7efad79e16f9c0212510db /src/main.cpp | |
parent | Fixed (diff) | |
download | GpgFrontend-ea7c0113486f336f3fe14435e1ce5eb55ad4eca9.tar.gz GpgFrontend-ea7c0113486f336f3fe14435e1ce5eb55ad4eca9.zip |
Fixed
1. Ci Fixed for New Version.
2. Bugs fixed for cross-platform.
3. Bugs fixed for i18n.
Diffstat (limited to '')
-rw-r--r-- | src/main.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index e3506064..82cfe9c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,8 +74,6 @@ int main(int argc, char* argv[]) { */ int return_from_event_loop_code; - LOG(INFO) << _("Resource Directory") << RESOURCE_DIR(app_path); - do { QApplication::setQuitOnLastWindowClosed(true); @@ -135,25 +133,41 @@ void init_locale() { settings.lookup("general").getType() != libconfig::Setting::TypeGroup) settings.add("general", libconfig::Setting::TypeGroup); + // set system default at first auto& general = settings["general"]; if (!general.exists("lang")) - general.add("lang", libconfig::Setting::TypeString) = - QLocale::system().name().toStdString(); + general.add("lang", libconfig::Setting::TypeString) = ""; GpgFrontend::UI::GlobalSettingStation::GetInstance().Sync(); + auto* locale_name = setlocale(LC_ALL, nullptr); + LOG(INFO) << "current system locale" << locale_name; + + // read from settings file std::string lang; if (!general.lookupValue("lang", lang)) { LOG(ERROR) << _("Could not read properly from configure file"); }; LOG(INFO) << "lang" << lang; + LOG(INFO) << "PROJECT_NAME" << PROJECT_NAME; + LOG(INFO) << "locales path" + << GpgFrontend::UI::GlobalSettingStation::GetInstance() + .GetLocaleDir() + .c_str(); + if (!lang.empty()) lang += ".UTF8"; // GNU gettext settings - setlocale(LC_ALL, lang.c_str()); + locale_name = setlocale(LC_ALL, lang.c_str()); + if (locale_name == nullptr) { + LOG(WARNING) << "set locale name failed"; + } else { + LOG(INFO) << "locale name now" << locale_name; + } + bindtextdomain(PROJECT_NAME, GpgFrontend::UI::GlobalSettingStation::GetInstance() .GetLocaleDir() - .c_str()); + .string().c_str()); textdomain(PROJECT_NAME); } |