MyGUI 3.5.3
MyGUI_LanguageManager.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_LANGUAGE_MANAGER_H_
8#define MYGUI_LANGUAGE_MANAGER_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Singleton.h"
12#include "MyGUI_XmlDocument.h"
13#include "MyGUI_Delegate.h"
14#include "MyGUI_Types.h"
16
17namespace MyGUI
18{
19
20 class Version;
21
22 class MYGUI_EXPORT LanguageManager : public MemberObsolete<LanguageManager>
23 {
24 MYGUI_SINGLETON_DECLARATION(LanguageManager);
25
26 public:
27 LanguageManager();
28
29 void initialise();
30 void shutdown();
31
33 void setCurrentLanguage(std::string_view _name);
35 const std::string& getCurrentLanguage() const;
37 VectorString getLanguages() const;
38
41 UString replaceTags(const UString& _line) const;
42
44 UString getTag(const UString& _tag) const;
45
47 void addUserTag(const UString& _tag, const UString& _replace);
48
50 void clearUserTags();
51
53 bool loadUserTags(const std::string& _file);
54
59 delegates::MultiDelegate<const std::string&> eventChangeLanguage;
60
67 delegates::Delegate<const UString&, UString&> eventRequestTag;
68
69 private:
70 void _load(xml::ElementPtr _node, std::string_view _file, Version _version);
71
72 bool loadLanguage(const std::string& _file, bool _user = false);
73 void _loadLanguageXML(IDataStream* _stream, bool _user);
74
75 UString replaceTagsPass(const UString& _line, bool& _replaceResult) const;
76
77 private:
78 using MapLanguageString = std::map<UString, UString, std::less<>>;
79
80 MapLanguageString mMapLanguage;
81 MapLanguageString mUserMapLanguage;
82
83 std::string mCurrentLanguageName;
84
85 using MapListString = std::map<std::string, VectorString, std::less<>>;
86 MapListString mMapFile;
87
88 bool mIsInitialise{false};
89 std::string mXmlLanguageTagName;
90 };
91
92} // namespace MyGUI
93
94#endif // MYGUI_LANGUAGE_MANAGER_H_
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
std::vector< std::string > VectorString
Definition MyGUI_Types.h:40