From 4d4e039da7a02725729e12f6715b6b5c5f516d42 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 25 Dec 2024 10:18:34 -0300 Subject: [PATCH] add an internationalization constant gather all ENGLISH|GERMAN|CHINESE etc preprocessor hell into a single library, so to restrict the number of targets that need to be built 8x this still has UB/EDITOR definitions so that still needs to be dealt with before we can build it only 8 times --- CMakeLists.txt | 2 ++ i18n/CMakeLists.txt | 4 ++++ i18n/include/language.hpp | 17 +++++++++++++++++ i18n/language.cpp | 24 ++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 i18n/CMakeLists.txt create mode 100644 i18n/include/language.hpp create mode 100644 i18n/language.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 139335b3..f1842724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ include_directories( "${CMAKE_SOURCE_DIR}/Multiplayer" "${CMAKE_SOURCE_DIR}/Editor" "${CMAKE_SOURCE_DIR}/Console" + "${CMAKE_SOURCE_DIR}/i18n/include" ) # external libraries @@ -85,6 +86,7 @@ Editor Console Tactical ModularizedTacticalAI +i18n ) foreach(lib IN LISTS Ja2_Libs) add_subdirectory(${lib}) diff --git a/i18n/CMakeLists.txt b/i18n/CMakeLists.txt new file mode 100644 index 00000000..e3100765 --- /dev/null +++ b/i18n/CMakeLists.txt @@ -0,0 +1,4 @@ +set(i18nSrc +"${CMAKE_CURRENT_SOURCE_DIR}/language.cpp" +PARENT_SCOPE +) diff --git a/i18n/include/language.hpp b/i18n/include/language.hpp new file mode 100644 index 00000000..469d104e --- /dev/null +++ b/i18n/include/language.hpp @@ -0,0 +1,17 @@ +#pragma once + +namespace i18n { +enum class Lang +{ + en, + de, + ru, + nl, + pl, + fr, + it, + zh +}; +} + +extern const i18n::Lang g_lang; diff --git a/i18n/language.cpp b/i18n/language.cpp new file mode 100644 index 00000000..4850fbca --- /dev/null +++ b/i18n/language.cpp @@ -0,0 +1,24 @@ +#include + +/* FIXME: The ugliest of ugly hacks. Getting rid of this and letting language + * (ideally text and voice separately) be set in the options menu would be + * ideal. */ +const i18n::Lang g_lang{ + #if defined(ENGLISH) + i18n::Lang::en +#elif defined(CHINESE) + i18n::Lang::zh +#elif defined(DUTCH) + i18n::Lang::nl +#elif defined(FRENCH) + i18n::Lang::fr +#elif defined(GERMAN) + i18n::Lang::de +#elif defined(ITALIAN) + i18n::Lang::it +#elif defined(POLISH) + i18n::Lang::pl +#elif defined(RUSSIAN) + i18n::Lang::ru +#endif +};