Skip to content

Commit

Permalink
finding gettext on windows eclipse-sumo#3 eclipse-sumo#11237
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Oct 10, 2022
1 parent 61213cb commit 2d9b425
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,16 @@ if (SUMO_LIBRARIES AND WIN32)
file(GLOB FOX_PATH "${SUMO_LIBRARIES}${LIB_VERSION}/fox-?.?.??")
file(GLOB FREETYPE_PATH "${SUMO_LIBRARIES}${LIB_VERSION}/freetype-2.??.?")
file(GLOB EIGEN3_PATH "${SUMO_LIBRARIES}/eigen-3.?.?")
file(GLOB GETTEXT_PATH "${SUMO_LIBRARIES}/gettext-?.??")
# set all paths in prefix
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${EIGEN3_PATH};${XERCES_PATH};${ZLIB_PATH};${PROJ_PATH};${FOX_PATH};${FREETYPE_PATH}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${EIGEN3_PATH};${XERCES_PATH};${ZLIB_PATH};${PROJ_PATH};${FOX_PATH};${FREETYPE_PATH};${GETTEXT_PATH}")
# save in variable SUMO_LIBRARIES_DLL all paths to dll files
file(GLOB SUMO_LIBRARIES_DLL "${XERCES_PATH}/bin/*.dll"
"${PROJ_PATH}/bin/*.dll"
"${FOX_PATH}/bin/*.dll"
"${ZLIB_PATH}/bin/*.dll"
# "${FREETYPE_PATH}/bin/*.dll"
"${GETTEXT_PATH}/bin/*.dll"
"${SUMO_LIBRARIES}${LIB_VERSION}/3rdPartyLibs/bzip2-*/bin/*.dll"
"${SUMO_LIBRARIES}${LIB_VERSION}/3rdPartyLibs/curl-*/bin/*.dll"
"${SUMO_LIBRARIES}${LIB_VERSION}/3rdPartyLibs/libpng-*/bin/*.dll"
Expand Down
10 changes: 8 additions & 2 deletions src/utils/common/MsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#include <utils/iodevices/OutputDevice.h>
#include <utils/common/UtilExceptions.h>
#include "MsgHandler.h"
#ifdef HAVE_INTL
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#endif


// ===========================================================================
Expand Down Expand Up @@ -229,12 +235,12 @@ void
MsgHandler::setupI18n(const std::string& locale) {
#ifdef HAVE_INTL
// inspired by https://erri120.github.io/posts/2022-05-05/
#if WIN32
#ifdef WIN32
// LocaleNameToLCID requires a LPCWSTR so we need to convert from char to wchar_t
const auto wStringSize = MultiByteToWideChar(CP_UTF8, 0, locale.data(), static_cast<int>(locale.length()), nullptr, 0);
std::wstring localeName;
localeName.reserve(wStringSize);
MultiByteToWideChar(CP_UTF8, 0, locale.data(), static_cast<int>(locale.length()), localeName.data(), wStringSize);
// MultiByteToWideChar(CP_UTF8, 0, locale.data(), static_cast<int>(locale.length()), localeName.data(), wStringSize);

_configthreadlocale(_DISABLE_PER_THREAD_LOCALE);
const auto localeId = LocaleNameToLCID(localeName.c_str(), LOCALE_ALLOW_NEUTRAL_NAMES);
Expand Down

0 comments on commit 2d9b425

Please sign in to comment.