2021-02-10 18:17:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-11 00:35:30 +01:00
|
|
|
#include <initializer_list>
|
2021-02-10 18:17:09 +01:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2021-02-11 00:35:30 +01:00
|
|
|
class LanguageDefinition {
|
|
|
|
public:
|
|
|
|
LanguageDefinition(std::initializer_list<std::pair<std::string, std::string>> entries);
|
|
|
|
|
|
|
|
const std::map<std::string, std::string>& getEntries() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<std::string, std::string> m_entries;
|
|
|
|
};
|
|
|
|
|
2021-02-10 18:17:09 +01:00
|
|
|
class LangEntry {
|
|
|
|
public:
|
2021-02-13 15:15:32 +01:00
|
|
|
explicit LangEntry(const char *unlocalizedString);
|
|
|
|
explicit LangEntry(const std::string &unlocalizedString);
|
|
|
|
explicit LangEntry(std::string_view unlocalizedString);
|
2021-02-10 18:17:09 +01:00
|
|
|
|
|
|
|
operator std::string() const;
|
|
|
|
operator std::string_view() const;
|
|
|
|
operator const char*() const;
|
|
|
|
|
2021-02-13 15:15:32 +01:00
|
|
|
[[nodiscard]] std::string_view get() const;
|
2021-02-10 18:17:09 +01:00
|
|
|
|
|
|
|
static void loadLanguage(std::string_view language);
|
|
|
|
static const std::map<std::string, std::string>& getSupportedLanguages();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_unlocalizedString;
|
|
|
|
};
|
|
|
|
|
2021-02-11 23:09:45 +01:00
|
|
|
std::string operator+(const std::string &&left, const LangEntry &&right);
|
|
|
|
std::string operator+(const LangEntry &&left, const std::string &&right);
|
|
|
|
std::string operator+(const std::string_view &&left, const LangEntry &&right);
|
|
|
|
std::string operator+(const LangEntry &&left, const std::string_view &&right);
|
|
|
|
std::string operator+(const char *left, const LangEntry &&right);
|
|
|
|
std::string operator+(const LangEntry &&left, const char *right);
|
|
|
|
std::string operator+(const LangEntry &&left, const LangEntry &&right);
|
|
|
|
|
2021-02-10 18:17:09 +01:00
|
|
|
namespace lang_literals {
|
|
|
|
|
2021-02-10 23:38:51 +01:00
|
|
|
inline LangEntry operator""_lang(const char *string, size_t) {
|
2021-02-10 18:17:09 +01:00
|
|
|
return LangEntry(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|