Planeshift
localization.h
Go to the documentation of this file.
1 /*
2  * localization.h - Author: Ondrej Hurt
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 
21 
22 #ifndef LOCALIZATION_HEADER
23 #define LOCALIZATION_HEADER
24 
25 #include <cstypes.h>
26 #include <csutil/hash.h>
27 #include <csutil/csstring.h>
28 
29 struct iObjectRegistry;
30 
36 {
37  csString original;
38  csString translated;
39 };
40 
41 typedef csHash<psStringTableItem*,csString> psStringTableHash;
42 
46 {
47 public:
49  ~psLocalization();
50 
51  void Initialize(iObjectRegistry* _object_reg);
52 
53  // Sets name of the language used by this program
54  void SetLanguage(const csString & lang);
55 
56  /* Converts stardard path to a file to the VFS path to it.
57  * It tries to search for the file in directory of the current language /this/lang/<language>/<shortPath> .
58  * If not found, then the standard path is simply returned back with "/this/" prefix.
59  *
60  * Examples of shortPath: "charpick.xml"
61  * "art/buttons/group.gif"
62  */
63  csString FindLocalizedFile(const csString & shortPath);
64 
66  const csString& Translate(const csString & orig);
67 
69  bool FileExists(const csString & fileName);
70 
71 protected:
72  void ClearStringTable();
73  void WriteStringTable();
74 
75  csString language;
76  csString filename;
77  csString authors;
78  bool dirty;
80  iObjectRegistry* object_reg;
81 };
82 
85 #endif
psStringTableHash stringTbl
Definition: localization.h:79
csHash< psStringTableItem *, csString > psStringTableHash
Definition: localization.h:41
iObjectRegistry * object_reg
Definition: localization.h:80
csString filename
Definition: localization.h:76
csString language
Definition: localization.h:75
void void Initialize(iObjectRegistry *object_reg)
Localization class for languages.
Definition: localization.h:45
csString translated
Definition: localization.h:38
csString authors
Definition: localization.h:77