OpenClonk
C4Language.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 /* Language module controlling external language packs */
18 
19 #ifndef INC_C4Language
20 #define INC_C4Language
21 
22 #include "c4group/C4Group.h"
23 #include "c4group/C4GroupSet.h"
25 
26 const int C4MaxLanguageInfo = 1024;
27 
29 {
30  friend class C4Language;
31 public:
32  char Code[2 + 1];
36 private:
37  C4LanguageInfo* Next;
38 };
39 
41 {
42 public:
43  C4Language();
44  ~C4Language();
45 private:
46  C4Group PackDirectory;
47  C4GroupSet Packs;
48  C4GroupSet PackGroups;
49  class C4LanguageInfo* Infos;
50  char PackGroupLocation[_MAX_FNAME_LEN];
51 public:
52  bool CloseGroup(const char *strPath);
53  void ClearLanguage();
54  // Initialization
55  bool Init();
56  void Clear();
57  // Handling of external language packs
58  int GetPackCount();
60  // Load a C4ComponentHost from all loaded language packs
61  static bool LoadComponentHost(C4ComponentHost *host, C4Group &hGroup, const char *szFilename, const char *szLanguage);
62 
63  // Handling of language info loaded from string tables
64  int GetInfoCount();
65  C4LanguageInfo *GetInfo(int iIndex);
66  C4LanguageInfo *FindInfo(const char *strCode);
67  // Loading of actual resource string table
68  bool LoadLanguage(const char *strLanguages);
69 
71 
72 private:
73  // Handling of language info loaded from string tables
74  void InitInfos();
75  void LoadInfos(C4Group &hGroup);
76  // Loading of actual resource string table
77  bool InitStringTable(const char *strCode);
78  bool LoadStringTable(C4Group &hGroup, const char *strCode);
79 };
80 
81 extern C4Language Languages;
82 
83 inline const char *LoadResStr(const char *id)
84 {
85  try
86  {
88  }
90  {
91  return id;
92  }
93 }
94 const char *LoadResStrNoAmp(const char *id);
95 
96 #endif
C4Language Languages
Definition: C4Language.cpp:42
const char * LoadResStrNoAmp(const char *id)
Definition: StdResStr2.cpp:23
const int C4MaxLanguageInfo
Definition: C4Language.h:26
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define _MAX_FNAME_LEN
const StdStrBuf & GetDataBuf() const
const std::string & Translate(const std::string &text) const
static C4LangStringTable & GetSystemStringTable()
C4LanguageInfo * FindInfo(const char *strCode)
Definition: C4Language.cpp:353
C4GroupSet GetPackGroups(C4Group &)
Definition: C4Language.cpp:148
void ClearLanguage()
Definition: C4Language.cpp:410
int GetInfoCount()
Definition: C4Language.cpp:138
bool Init()
Definition: C4Language.cpp:55
bool CloseGroup(const char *strPath)
Definition: C4Language.cpp:418
int GetPackCount()
Definition: C4Language.cpp:133
static bool LoadComponentHost(C4ComponentHost *host, C4Group &hGroup, const char *szFilename, const char *szLanguage)
Definition: C4Language.cpp:232
void Clear()
Definition: C4Language.cpp:114
C4LanguageInfo * GetInfo(int iIndex)
Definition: C4Language.cpp:343
bool LoadLanguage(const char *strLanguages)
Definition: C4Language.cpp:361
bool HasStringTable() const
Definition: C4Language.h:70
char Name[C4MaxLanguageInfo+1]
Definition: C4Language.h:33
char Code[2+1]
Definition: C4Language.h:32
char Fallback[C4MaxLanguageInfo+1]
Definition: C4Language.h:35
char Info[C4MaxLanguageInfo+1]
Definition: C4Language.h:34
bool isNull() const
Definition: StdBuf.h:441