From 8d30791595cf981b08310472faa2066a99aa9595 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 31 Dec 2013 17:20:03 +0100 Subject: Ability to set language via ini file If language autodetection doesn't work, someone might want to manually force the game to use correct language without using -language parameter every time --- src/app/app.cpp | 10 ++++++++++ src/common/profile.cpp | 16 ++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index 566be33..8b5533e 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -425,6 +425,16 @@ bool CApplication::Create() return false; } + if (GetProfile().GetLocalProfileString("Language", "Lang", path)) { + Language language; + if (ParseLanguage(path, language)) { + m_language = language; + GetLogger()->Error("Setting language '%s' from ini file\n", path.c_str()); + } else { + GetLogger()->Error("Invalid language '%s' in ini file\n", path.c_str()); + } + } + SetLanguage(m_language); //Create the sound instance. diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 77c70c3..ee3e873 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -91,7 +91,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -106,7 +106,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -122,7 +122,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -137,7 +137,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -153,7 +153,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -168,7 +168,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -178,7 +178,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, std::string key) { std::vector< std::string > ret_list; - boost::regex re(key + "[0-9]*"); //we want to match all key followed my any number + boost::regex re(key + "[0-9]*"); //we want to match all key followed by any number try { @@ -192,7 +192,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, } catch (std::exception & e) { - GetLogger()->Error("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on parsing profile: %s\n", e.what()); } return ret_list; -- cgit v1.2.3-1-g7c22