Fixed updating C locale after exception in C++ locale, should finish fixing #445
parent
9c20f275a0
commit
bb16c6d97c
|
@ -1683,10 +1683,11 @@ void CApplication::SetLanguage(Language language)
|
|||
GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str());
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, ""); // Load system locale
|
||||
char* defaultLocale = setlocale(LC_ALL, ""); // Load system locale
|
||||
setlocale(LC_NUMERIC, "C"); // Force numeric locale to "C" (fixes decimal point problems)
|
||||
char* systemLocale = setlocale(LC_ALL, nullptr); // Get current locale configuration
|
||||
GetLogger()->Debug("System locale: %s\n", systemLocale);
|
||||
GetLogger()->Debug("Default system locale: %s\n", defaultLocale);
|
||||
GetLogger()->Debug("Setting locale: %s\n", systemLocale);
|
||||
// Update C++ locale
|
||||
try
|
||||
{
|
||||
|
@ -1698,12 +1699,15 @@ void CApplication::SetLanguage(Language language)
|
|||
try
|
||||
{
|
||||
std::locale::global(std::locale::classic());
|
||||
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");
|
||||
GetLogger()->Warn("Failed to set classic locale. Something is really messed up in your system configuration. Translations might not work.\n");
|
||||
}
|
||||
|
||||
// C locale might still work correctly
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
}
|
||||
|
||||
bindtextdomain("colobot", m_pathManager->GetLangPath().c_str());
|
||||
|
|
Loading…
Reference in New Issue