diff --git a/src/EmbeddedResources/FlightGear-resources.xml b/src/EmbeddedResources/FlightGear-resources.xml new file mode 100644 index 000000000..1cb61f497 --- /dev/null +++ b/src/EmbeddedResources/FlightGear-resources.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index f1c22e075..68a86f09b 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -22,6 +22,7 @@ set(SOURCES subsystemFactory.cxx screensaver_control.cxx ${RESOURCE_FILE} + ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx ) set(HEADERS @@ -40,8 +41,17 @@ set(HEADERS subsystemFactory.hxx AircraftDirVisitorBase.hxx screensaver_control.hxx + ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx ) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx + ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx + COMMAND fgrcc --root=${CMAKE_SOURCE_DIR} --output-cpp-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx --init-func-name=initFlightGearEmbeddedResources --output-header-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx --output-header-identifier=_FG_FLIGHTGEAR_EMBEDDED_RESOURCES ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml + DEPENDS + fgrcc ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml + ) + get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES) get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index edb464ef2..8bd45ded9 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -60,6 +60,7 @@ #include #include #include +#include #include #include @@ -107,6 +108,7 @@ #include #include #include +#include
#include #include #include @@ -1117,7 +1119,14 @@ void fgStartNewReset() fgInitGeneral(); // all of this? flightgear::Options::sharedInstance()->processOptions(); - + + const auto& resMgr = simgear::EmbeddedResourceManager::instance(); + // The language was (re)set in processOptions() + const string locale = globals->get_locale()->getPreferredLanguage(); + resMgr->selectLocale(locale); + SG_LOG(SG_GENERAL, SG_INFO, + "EmbeddedResourceManager: selected locale '" << locale << "'"); + // PRESERVED properties over-write state from options, intentionally if ( copyProperties(preserved, globals->get_props()) ) { SG_LOG( SG_GENERAL, SG_INFO, "Preserved state restored successfully" ); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index b7ee1e67e..c72db1c3a 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -56,6 +56,7 @@ extern bool global_crashRptEnabled; #include #include +#include
#include #include #include @@ -80,6 +81,9 @@ extern bool global_crashRptEnabled; #include "subsystemFactory.hxx" #include "options.hxx" +#include +#include + #if defined(HAVE_QT) #include #endif @@ -537,6 +541,15 @@ int fgMainInit( int argc, char **argv ) return EXIT_SUCCESS; } + const auto& resMgr = simgear::EmbeddedResourceManager::createInstance(); + initFlightGearEmbeddedResources(); + // The language was set in processOptions() + const std::string locale = globals->get_locale()->getPreferredLanguage(); + // Must always be done after all resources have been added to 'resMgr' + resMgr->selectLocale(locale); + SG_LOG(SG_GENERAL, SG_INFO, + "EmbeddedResourceManager: selected locale '" << locale << "'"); + // Initialize the Window/Graphics environment. fgOSInit(&argc, argv); _bootstrap_OSInit++;