blob: de32cf829d51baa7d4c6a01c52ce95fedec3d7e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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<> OnReload;
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:
const char* mContent;
public:
BasicTranslation(std::string_view key);
const char* 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
};
|