MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_LANGUAGE_MANAGER_H__ 00023 #define __MYGUI_LANGUAGE_MANAGER_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Singleton.h" 00027 #include "MyGUI_XmlDocument.h" 00028 #include "MyGUI_Delegate.h" 00029 #include "MyGUI_Types.h" 00030 #include "MyGUI_BackwardCompatibility.h" 00031 00032 namespace MyGUI 00033 { 00034 00035 class MYGUI_EXPORT LanguageManager : 00036 public Singleton<LanguageManager>, 00037 public MemberObsolete<LanguageManager> 00038 { 00039 public: 00040 LanguageManager(); 00041 00042 void initialise(); 00043 void shutdown(); 00044 00046 void setCurrentLanguage(const std::string& _name); 00048 const std::string& getCurrentLanguage() const; 00049 00052 UString replaceTags(const UString& _line); 00053 00055 UString getTag(const UString& _tag); 00056 00058 void addUserTag(const UString& _tag, const UString& _replace); 00059 00061 void clearUserTags(); 00062 00064 bool loadUserTags(const std::string& _file); 00065 00070 delegates::CMultiDelegate1<const std::string&> 00071 eventChangeLanguage; 00072 00079 delegates::CDelegate2<const UString&, UString&> 00080 eventRequestTag; 00081 00082 private: 00083 void _load(xml::ElementPtr _node, const std::string& _file, Version _version); 00084 00085 bool loadLanguage(const std::string& _file, bool _user = false); 00086 void _loadLanguage(IDataStream* _stream, bool _user); 00087 void _loadLanguageXML(IDataStream* _stream, bool _user); 00088 00089 UString replaceTagsPass(const UString& _line, bool& _replaceResult); 00090 00091 private: 00092 typedef std::map<UString, UString> MapLanguageString; 00093 00094 MapLanguageString mMapLanguage; 00095 MapLanguageString mUserMapLanguage; 00096 00097 std::string mCurrentLanguageName; 00098 00099 typedef std::map<std::string, VectorString> MapListString; 00100 MapListString mMapFile; 00101 00102 bool mIsInitialise; 00103 }; 00104 00105 } // namespace MyGUI 00106 00107 #endif // __MYGUI_LANGUAGE_MANAGER_H__