This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit 87cf056158c9cb208b6fb2701118c82a2f29e660
Author: krzys-h <krzy...@interia.pl>
Date:   Sat Mar 21 13:09:05 2015 +0100

    Modified locale setting code
    
    I'm doing my best to fix #445. At least shouldn't crash anymore.
    Needs more testing.
---
 src/app/app.cpp | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/app/app.cpp b/src/app/app.cpp
index d0e783d..72adb0f 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -1682,8 +1682,29 @@ void CApplication::SetLanguage(Language language)
         putenv(S_LANGUAGE);
         GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", 
locale.c_str());
     }
-    
-    std::locale::global(std::locale(std::locale(""), "C", 
std::locale::numeric));
+
+    std::setlocale(LC_ALL, ""); // Load system locale
+    std::setlocale(LC_NUMERIC, "C"); // Force numeric locale to "C" (fixes 
decimal point problems)
+    char* systemLocale = std::setlocale(LC_ALL, nullptr); // Get current 
locale configuration
+    GetLogger()->Debug("System locale: %s\n", systemLocale);
+    // Update C++ locale
+    try
+    {
+        std::locale::global(std::locale(systemLocale));
+    }
+    catch(...)
+    {
+        GetLogger()->Warn("Failed to update locale, possibly incorect system 
configuration. Will fallback to classic locale.\n");
+        try
+        {
+            std::locale::global(std::locale::classic());
+            std::setlocale(LC_ALL, systemLocale); // C locale might still work 
correctly
+        }
+        catch(...)
+        {
+            GetLogger()->Warn("Failed to set classic locale. Something is 
really messed up in your system configuration. Translations probably won't 
work.\n");
+        }
+    }
 
     bindtextdomain("colobot", m_pathManager->GetLangPath().c_str());
     bind_textdomain_codeset("colobot", "UTF-8");

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/colobot.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to