MyGUI: MyGUI_LanguageManager.h Source File

MyGUI 3.4.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"
15#include "MyGUI_BackwardCompatibility.h"
16
17namespace MyGUI
18{
19
20 class MYGUI_EXPORT LanguageManager : public MemberObsolete<LanguageManager>
21 {
22 MYGUI_SINGLETON_DECLARATION(LanguageManager);
23
24 public:
25 LanguageManager();
26
27 void initialise();
28 void shutdown();
29
31 void setCurrentLanguage(std::string_view _name);
33 const std::string& getCurrentLanguage() const;
35 VectorString getLanguages() const;
36
39 UString replaceTags(const UString& _line);
40
42 UString getTag(const UString& _tag) const;
43
45 void addUserTag(const UString& _tag, const UString& _replace);
46
48 void clearUserTags();
49
51 bool loadUserTags(const std::string& _file);
52
57 delegates::MultiDelegate<const std::string&> eventChangeLanguage;
58
65 delegates::Delegate<const UString&, UString&> eventRequestTag;
66
67 private:
68 void _load(xml::ElementPtr _node, std::string_view _file, Version _version);
69
70 bool loadLanguage(const std::string& _file, bool _user = false);
71 void _loadLanguage(IDataStream* _stream, bool _user);
72 void _loadLanguageXML(IDataStream* _stream, bool _user);
73
74 UString replaceTagsPass(const UString& _line, bool& _replaceResult);
75
76 private:
77 using MapLanguageString = std::map<UString, UString, std::less<>>;
78
79 MapLanguageString mMapLanguage;
80 MapLanguageString mUserMapLanguage;
81
82 std::string mCurrentLanguageName;
83
84 using MapListString = std::map<std::string, VectorString, std::less<>>;
85 MapListString mMapFile;
86
87 bool mIsInitialise{false};
88 std::string mXmlLanguageTagName;
89 };
90
91} // namespace MyGUI
92
93#endif // MYGUI_LANGUAGE_MANAGER_H_
MyGUI_BackwardCompatibility.h
MyGUI_Delegate.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_Singleton.h
MYGUI_SINGLETON_DECLARATION
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Definition MyGUI_Singleton.h:112
MyGUI_Types.h
MyGUI_XmlDocument.h
MyGUI::IDataStream
Definition MyGUI_IDataStream.h:17
MyGUI::LanguageManager::LanguageManager
LanguageManager(const LanguageManager &)=delete
MyGUI::LanguageManager::eventChangeLanguage
delegates::MultiDelegate< const std::string & > eventChangeLanguage
Definition MyGUI_LanguageManager.h:57
MyGUI::LanguageManager::setCurrentLanguage
void setCurrentLanguage(std::string_view _name)
Definition MyGUI_LanguageManager.cpp:104
MyGUI::LanguageManager::clearUserTags
void clearUserTags()
Definition MyGUI_LanguageManager.cpp:250
MyGUI::LanguageManager::initialise
void initialise()
Definition MyGUI_LanguageManager.cpp:26
MyGUI::LanguageManager::getCurrentLanguage
const std::string & getCurrentLanguage() const
Definition MyGUI_LanguageManager.cpp:229
MyGUI::LanguageManager::eventRequestTag
delegates::Delegate< const UString &, UString & > eventRequestTag
Definition MyGUI_LanguageManager.h:65
MyGUI::LanguageManager::addUserTag
void addUserTag(const UString &_tag, const UString &_replace)
Definition MyGUI_LanguageManager.cpp:245
MyGUI::LanguageManager::getLanguages
VectorString getLanguages() const
Definition MyGUI_LanguageManager.cpp:235
MyGUI::LanguageManager::getTag
UString getTag(const UString &_tag) const
Definition MyGUI_LanguageManager.cpp:212
MyGUI::LanguageManager::shutdown
void shutdown()
Definition MyGUI_LanguageManager.cpp:38
MyGUI::LanguageManager::loadUserTags
bool loadUserTags(const std::string &_file)
Definition MyGUI_LanguageManager.cpp:255
MyGUI::LanguageManager::replaceTags
UString replaceTags(const UString &_line)
Definition MyGUI_LanguageManager.cpp:199
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::Version
Definition MyGUI_Version.h:18
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:158
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI::xml::ElementPtr
Element * ElementPtr
Definition MyGUI_XmlDocument.h:112
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::VectorString
std::vector< std::string > VectorString
Definition MyGUI_Types.h:41