forked from kovacsv/VisualScriptEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNE_Localization.hpp
More file actions
66 lines (49 loc) · 1.56 KB
/
Copy pathNE_Localization.hpp
File metadata and controls
66 lines (49 loc) · 1.56 KB
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
#ifndef NE_LOCALIZATION_HPP
#define NE_LOCALIZATION_HPP
#include <string>
#include <functional>
#include <unordered_map>
#include <unordered_set>
namespace NE
{
class DictionarySource
{
public:
DictionarySource ();
virtual ~DictionarySource ();
virtual bool EnumerateEntries (const std::function<bool (const std::wstring&, const std::wstring&)>& processor) = 0;
};
class Dictionary
{
public:
Dictionary ();
void Clear ();
bool IsEmpty () const;
bool AddLocalizedString (const std::wstring& id, const std::wstring& str);
bool HasLocalizedString (const std::wstring& id) const;
std::wstring GetLocalizedString (const std::wstring& id) const;
private:
std::unordered_map<std::wstring, std::wstring> dictionary;
};
class NonLocalizedCollector
{
public:
NonLocalizedCollector ();
virtual ~NonLocalizedCollector ();
virtual void NonLocalizedStringFound (const std::wstring& str) = 0;
};
class NonLocalizedCollectorGuard
{
public:
NonLocalizedCollectorGuard (NonLocalizedCollector* collector);
~NonLocalizedCollectorGuard ();
};
void SetNonLocalizedCollector (NonLocalizedCollector* collector);
// Replaces all %S symbols in the format string with the corresponding string.
std::wstring FormatString (const std::wstring& format, const std::initializer_list<std::wstring>& strings);
bool FillDictionary (Dictionary& dictionary, DictionarySource& source);
std::wstring LocalizeString (const Dictionary& dictionary, const std::wstring& str);
bool FillDictionary (DictionarySource& source);
std::wstring LocalizeString (const std::wstring& str);
}
#endif