summaryrefslogtreecommitdiff
path: root/core/src/Utils/I18n.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Utils/I18n.hpp')
-rw-r--r--core/src/Utils/I18n.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/core/src/Utils/I18n.hpp b/core/src/Utils/I18n.hpp
new file mode 100644
index 0000000..6b72d29
--- /dev/null
+++ b/core/src/Utils/I18n.hpp
@@ -0,0 +1,69 @@
+#pragma once
+
+#include "Utils/Sigslot.hpp"
+#include "Utils/fwd.hpp"
+
+#include <cstddef>
+#include <optional>
+#include <span>
+#include <string>
+#include <string_view>
+#include <variant>
+#include <vector>
+
+class I18n {
+public:
+ static void Init();
+ static void Shutdown();
+
+ static Signal<> reloadSignal;
+ static void ReloadLocales();
+
+ static std::string_view GetLanguage();
+ static bool SetLanguage(std::string_view lang);
+
+ static std::optional<std::string_view> Lookup(std::string_view key);
+ static std::string_view LookupUnwrap(std::string_view key);
+ static std::string_view LookupLanguage(std::string_view lang);
+};
+
+struct StringArgument {
+ std::string Value;
+};
+
+struct IntArgument {
+ int Value;
+};
+
+struct FloatArgument {
+ double Value;
+};
+
+class BasicTranslation {
+private:
+ std::string_view mContent;
+
+public:
+ BasicTranslation(std::string_view key);
+ std::string_view Get() const;
+};
+
+class FormattedTranslation {
+public:
+ using Element = std::variant<std::string, int>;
+ using Argument = std::string;
+
+private:
+ std::vector<Element> mParsedElements;
+ size_t mNumArguments;
+ size_t mMinimumResultLen;
+
+public:
+ FormattedTranslation(std::string_view key);
+ std::string Format(std::span<Argument> args);
+};
+
+class NumericTranslation {
+public:
+ // TODO
+};