From acfd5271feb349b96a66d3285726fd9b1f693083 Mon Sep 17 00:00:00 2001 From: Christof Ruch Date: Thu, 10 Mar 2022 23:37:59 +0100 Subject: [PATCH] [i18n] Fix Linux UTF8 switch, and log in case the ::setlocale() indicates failure with a NULL return. --- I18NHelper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/I18NHelper.cpp b/I18NHelper.cpp index ec548f0..b703665 100644 --- a/I18NHelper.cpp +++ b/I18NHelper.cpp @@ -67,10 +67,10 @@ void globalSetupLocale() SimpleLogger::instance()->postMessage("Bindtext domain gave us " + String(result)); #if defined(WIN32) || defined(__APPLE__) std::string displayLocale = juce::SystemStats::getDisplayLanguage().toStdString(); - bind_textdomain_codeset(USE_GETTEXT_TEXT_DOMAIN, "utf-8"); #else std::string displayLocale = ::setlocale (LC_MESSAGES, ""); #endif + bind_textdomain_codeset(USE_GETTEXT_TEXT_DOMAIN, "utf-8"); switchDisplayLanguage(displayLocale.c_str()); } @@ -90,7 +90,10 @@ void switchDisplayLanguage(const char* languageID) setenv("LANG", localeToSet, 1); #endif #else - ::setlocale(LC_MESSAGES, languageID); + auto returnValue = ::setlocale(LC_MESSAGES, languageID); + if (returnValue == nullptr) { + SimpleLogger::instance()->postMessage("User locale " + String(languageID) + " requested but error returned"); + } localeToSet = languageID; #endif