MyGUI_LanguageManager.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_LANGUAGE_MANAGER_H_
#define MYGUI_LANGUAGE_MANAGER_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Singleton.h"
#include "MyGUI_XmlDocument.h"
#include "MyGUI_Delegate.h"
#include "MyGUI_Types.h"
#include "MyGUI_BackwardCompatibility.h"
namespace MyGUI
{
class MYGUI_EXPORT LanguageManager : public MemberObsolete<LanguageManager>
{
MYGUI_SINGLETON_DECLARATION(LanguageManager);
public:
LanguageManager();
void initialise();
void shutdown();
void setCurrentLanguage(std::string_view _name);
const std::string& getCurrentLanguage() const;
VectorString getLanguages() const;
UString replaceTags(const UString& _line);
UString getTag(const UString& _tag) const;
void addUserTag(const UString& _tag, const UString& _replace);
void clearUserTags();
bool loadUserTags(const std::string& _file);
delegates::MultiDelegate<const std::string&> eventChangeLanguage;
delegates::Delegate<const UString&, UString&> eventRequestTag;
private:
void _load(xml::ElementPtr _node, std::string_view _file, Version _version);
bool loadLanguage(const std::string& _file, bool _user = false);
void _loadLanguage(IDataStream* _stream, bool _user);
void _loadLanguageXML(IDataStream* _stream, bool _user);
UString replaceTagsPass(const UString& _line, bool& _replaceResult);
private:
using MapLanguageString = std::map<UString, UString, std::less<>>;
MapLanguageString mMapLanguage;
MapLanguageString mUserMapLanguage;
std::string mCurrentLanguageName;
using MapListString = std::map<std::string, VectorString, std::less<>>;
MapListString mMapFile;
bool mIsInitialise{false};
std::string mXmlLanguageTagName;
};
} // namespace MyGUI
#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