# HG changeset patch # User Sebastien Jodogne # Date 1500042856 -7200 # Node ID 9c7a80c87ae975e0bba626436de5a49d35fbb1a3 # Parent 55c900a5b0e419b77840ed673c6f7c740d8d7f8a "Locale" configuration option diff -r 55c900a5b0e4 -r 9c7a80c87ae9 Core/Toolbox.cpp --- a/Core/Toolbox.cpp Fri Jul 14 16:17:02 2017 +0200 +++ b/Core/Toolbox.cpp Fri Jul 14 16:34:16 2017 +0200 @@ -1256,7 +1256,7 @@ static std::auto_ptr globalLocale_; - void Toolbox::InitializeGlobalLocale() + void Toolbox::InitializeGlobalLocale(const char* locale) { // Make Orthanc use English, United States locale @@ -1270,18 +1270,25 @@ try { - if (DEFAULT_LOCALE == NULL) + if (locale != NULL) { + LOG(WARNING) << "Using user-specified locale: \"" << locale << "\""; + globalLocale_.reset(new std::locale(locale)); + } + else if (DEFAULT_LOCALE == NULL) + { + LOG(WARNING) << "Using system-wide default locale"; globalLocale_.reset(new std::locale()); } else { + LOG(WARNING) << "Using default locale: \"" << DEFAULT_LOCALE << "\""; globalLocale_.reset(new std::locale(DEFAULT_LOCALE)); } } - catch (std::runtime_error& e) + catch (std::runtime_error&) { - LOG(ERROR) << "Cannot initialize global locale as \"" << DEFAULT_LOCALE << "\""; + LOG(ERROR) << "Cannot initialize global locale"; throw OrthancException(ErrorCode_InternalError); } } diff -r 55c900a5b0e4 -r 9c7a80c87ae9 Core/Toolbox.h --- a/Core/Toolbox.h Fri Jul 14 16:17:02 2017 +0200 +++ b/Core/Toolbox.h Fri Jul 14 16:34:16 2017 +0200 @@ -207,7 +207,7 @@ bool StartsWithUuid(const std::string& str); - void InitializeGlobalLocale(); + void InitializeGlobalLocale(const char* locale); void FinalizeGlobalLocale(); diff -r 55c900a5b0e4 -r 9c7a80c87ae9 NEWS --- a/NEWS Fri Jul 14 16:17:02 2017 +0200 +++ b/NEWS Fri Jul 14 16:34:16 2017 +0200 @@ -12,6 +12,7 @@ - Obsolete manufacturers are still accepted but might disappear in the future - Added new manufacturer: GenericNoWidlcards to replace all '*' by '' in outgoing C-Find requests +* "Locale" configuration option REST API -------- diff -r 55c900a5b0e4 -r 9c7a80c87ae9 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Fri Jul 14 16:17:02 2017 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Fri Jul 14 16:34:16 2017 +0200 @@ -464,7 +464,6 @@ { boost::recursive_mutex::scoped_lock lock(globalMutex_); - Toolbox::InitializeGlobalLocale(); HttpClient::InitializeOpenSsl(); InitializeServerEnumerations(); @@ -473,6 +472,16 @@ ReadGlobalConfiguration(configurationFile); ValidateGlobalConfiguration(); + if (configuration_.isMember("Locale")) + { + std::string locale = GetGlobalStringParameterInternal("Locale", ""); + Toolbox::InitializeGlobalLocale(configuration_["Locale"].asCString()); + } + else + { + Toolbox::InitializeGlobalLocale(NULL); + } + if (configuration_.isMember("Pkcs11")) { ConfigurePkcs11(configuration_["Pkcs11"]); diff -r 55c900a5b0e4 -r 9c7a80c87ae9 Resources/Configuration.json --- a/Resources/Configuration.json Fri Jul 14 16:17:02 2017 +0200 +++ b/Resources/Configuration.json Fri Jul 14 16:34:16 2017 +0200 @@ -334,6 +334,10 @@ // interest in the "Dictionary" configuration option below. "LoadPrivateDictionary" : true, + // Locale to be used by Orthanc. Notably used if comparing strings + // in a case-insensitive way. + // "Locale" : "en_US.UTF-8", + // Register a new tag in the dictionary of DICOM tags that are known // to Orthanc. Each line must contain the tag (formatted as 2 // hexadecimal numbers), the value representation (2 upcase