MyGUI  3.2.0
MyGUI_LanguageManager.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_LANGUAGE_MANAGER_H__
23 #define __MYGUI_LANGUAGE_MANAGER_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Singleton.h"
27 #include "MyGUI_XmlDocument.h"
28 #include "MyGUI_Delegate.h"
29 #include "MyGUI_Types.h"
31 
32 namespace MyGUI
33 {
34 
36  public Singleton<LanguageManager>,
37  public MemberObsolete<LanguageManager>
38  {
39  public:
41 
42  void initialise();
43  void shutdown();
44 
46  void setCurrentLanguage(const std::string& _name);
48  const std::string& getCurrentLanguage() const;
49 
52  UString replaceTags(const UString& _line);
53 
55  UString getTag(const UString& _tag);
56 
58  void addUserTag(const UString& _tag, const UString& _replace);
59 
61  void clearUserTags();
62 
64  bool loadUserTags(const std::string& _file);
65 
72 
81 
82  private:
83  void _load(xml::ElementPtr _node, const std::string& _file, Version _version);
84 
85  bool loadLanguage(const std::string& _file, bool _user = false);
86  void _loadLanguage(IDataStream* _stream, bool _user);
87  void _loadLanguageXML(IDataStream* _stream, bool _user);
88 
89  UString replaceTagsPass(const UString& _line, bool& _replaceResult);
90 
91  private:
92  typedef std::map<UString, UString> MapLanguageString;
93 
94  MapLanguageString mMapLanguage;
95  MapLanguageString mUserMapLanguage;
96 
97  std::string mCurrentLanguageName;
98 
99  typedef std::map<std::string, VectorString> MapListString;
100  MapListString mMapFile;
101 
102  bool mIsInitialise;
103  };
104 
105 } // namespace MyGUI
106 
107 #endif // __MYGUI_LANGUAGE_MANAGER_H__