comparison Core/Toolbox.cpp @ 2330:9c7a80c87ae9

"Locale" configuration option
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Jul 2017 16:34:16 +0200
parents 423d3b692bb9
children 6677cdbfbafd
comparison
equal deleted inserted replaced
2329:55c900a5b0e4 2330:9c7a80c87ae9
1254 } 1254 }
1255 1255
1256 1256
1257 static std::auto_ptr<std::locale> globalLocale_; 1257 static std::auto_ptr<std::locale> globalLocale_;
1258 1258
1259 void Toolbox::InitializeGlobalLocale() 1259 void Toolbox::InitializeGlobalLocale(const char* locale)
1260 { 1260 {
1261 // Make Orthanc use English, United States locale 1261 // Make Orthanc use English, United States locale
1262 1262
1263 #if defined(_WIN32) 1263 #if defined(_WIN32)
1264 // For Windows: use default locale (one might use "en-US" instead) 1264 // For Windows: use default locale (one might use "en-US" instead)
1268 static const char* DEFAULT_LOCALE = "en_US.UTF-8"; 1268 static const char* DEFAULT_LOCALE = "en_US.UTF-8";
1269 #endif 1269 #endif
1270 1270
1271 try 1271 try
1272 { 1272 {
1273 if (DEFAULT_LOCALE == NULL) 1273 if (locale != NULL)
1274 { 1274 {
1275 LOG(WARNING) << "Using user-specified locale: \"" << locale << "\"";
1276 globalLocale_.reset(new std::locale(locale));
1277 }
1278 else if (DEFAULT_LOCALE == NULL)
1279 {
1280 LOG(WARNING) << "Using system-wide default locale";
1275 globalLocale_.reset(new std::locale()); 1281 globalLocale_.reset(new std::locale());
1276 } 1282 }
1277 else 1283 else
1278 { 1284 {
1285 LOG(WARNING) << "Using default locale: \"" << DEFAULT_LOCALE << "\"";
1279 globalLocale_.reset(new std::locale(DEFAULT_LOCALE)); 1286 globalLocale_.reset(new std::locale(DEFAULT_LOCALE));
1280 } 1287 }
1281 } 1288 }
1282 catch (std::runtime_error& e) 1289 catch (std::runtime_error&)
1283 { 1290 {
1284 LOG(ERROR) << "Cannot initialize global locale as \"" << DEFAULT_LOCALE << "\""; 1291 LOG(ERROR) << "Cannot initialize global locale";
1285 throw OrthancException(ErrorCode_InternalError); 1292 throw OrthancException(ErrorCode_InternalError);
1286 } 1293 }
1287 } 1294 }
1288 1295
1289 1296