-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguageManager.h
More file actions
30 lines (24 loc) · 881 Bytes
/
Copy pathLanguageManager.h
File metadata and controls
30 lines (24 loc) · 881 Bytes
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
#ifndef LANGUAGEMANAGER_H
#define LANGUAGEMANAGER_H
#include <wx/string.h>
#include <map>
class LanguageManager {
public:
static LanguageManager& Get();
bool LoadLanguage(const wxString& langCode);
// Parses translation JSON that has already been loaded into memory.
// Kept separate from LoadLanguage so it can be unit-tested without any
// filesystem or Windows-resource access.
bool LoadFromContent(const wxString& langCode, const wxString& content);
wxString GetString(const wxString& key) const;
wxString GetCurrentLanguage() const { return m_currentLang; }
private:
LanguageManager() = default;
std::map<wxString, wxString> m_strings;
wxString m_currentLang;
};
// Global helper for translations
inline wxString L(const wxString& key) {
return LanguageManager::Get().GetString(key);
}
#endif // LANGUAGEMANAGER_H