locale: move localised strings to cpp impl (#40)

This commit is contained in:
Hyper
2024-12-15 15:15:32 +00:00
committed by GitHub
parent c6e3d4e31f
commit 74ee0c2b2f
8 changed files with 356 additions and 373 deletions
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include <user/config_detail.h>
#include <locale/config_locale.h>
#include <user/paths.h>
#include <exports.h>
+5 -2
View File
@@ -1,5 +1,6 @@
#include "config.h"
#include "config_detail.h"
#include <locale/locale.h>
// CONFIG_DEFINE
template<typename T>
@@ -100,7 +101,9 @@ std::string ConfigDef<T>::GetValueLocalised() const
}
else if constexpr (std::is_same_v<T, bool>)
{
locale = &g_bool_locale;
return Value
? Localise("Common_On")
: Localise("Common_Off");
}
if (!locale)
@@ -138,7 +141,7 @@ std::string ConfigDef<T>::GetValueDescription() const
}
else if constexpr (std::is_same_v<T, bool>)
{
locale = &g_bool_locale;
return "";
}
if (!locale)
+7 -3
View File
@@ -1,26 +1,30 @@
#pragma once
#define CONFIG_LOCALE std::unordered_map<ELanguage, std::tuple<std::string, std::string>>
#define CONFIG_ENUM_LOCALE(type) std::unordered_map<ELanguage, std::unordered_map<type, std::tuple<std::string, std::string>>>
#define CONFIG_DEFINE(section, type, name, defaultValue) \
static inline ConfigDef<type> name{section, #name, defaultValue};
#define CONFIG_DEFINE_LOCALISED(section, type, name, defaultValue) \
static CONFIG_LOCALE g_##name##_locale; \
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
#define CONFIG_DEFINE_ENUM(section, type, name, defaultValue) \
static inline ConfigDef<type> name{section, #name, defaultValue, &g_##type##_template};
#define CONFIG_DEFINE_ENUM_LOCALISED(section, type, name, defaultValue) \
static CONFIG_LOCALE g_##name##_locale; \
static CONFIG_ENUM_LOCALE(type) g_##type##_locale; \
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue, &g_##type##_template, &g_##type##_locale};
#define CONFIG_DEFINE_CALLBACK(section, type, name, defaultValue, readCallback) \
static CONFIG_LOCALE g_##name##_locale; \
static inline ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type>* def) readCallback};
#define CONFIG_DEFINE_ENUM_TEMPLATE(type) \
inline std::unordered_map<std::string, type> g_##type##_template =
#define CONFIG_LOCALE std::unordered_map<ELanguage, std::tuple<std::string, std::string>>
#define CONFIG_ENUM_LOCALE(type) std::unordered_map<ELanguage, std::unordered_map<type, std::tuple<std::string, std::string>>>
#define WINDOWPOS_CENTRED 0x2FFF0000
enum class ELanguage : uint32_t