KVIrc  4.9.2
DeveloperAPIs
KviLocale.h
Go to the documentation of this file.
1 #ifndef _KVI_LOCALE_H_
2 #define _KVI_LOCALE_H_
3 
4 //=============================================================================
5 //
6 // File : KviLocale.h
7 // Creation date : Sat Jan 16 1999 18:15:01 by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 1999-2010 Szymon Stefanek (pragma at kvirc dot net)
11 // Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
12 //
13 // This program is FREE software. You can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the HOPE that it will be USEFUL,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 // See the GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program. If not, write to the Free Software Foundation,
25 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 //
27 //=============================================================================
28 
35 #include "kvi_settings.h"
36 #include "KviHeapObject.h"
37 #include "KviMessageCatalogue.h"
38 
39 class KviCString;
40 class QApplication;
41 class QString;
42 class QTextCodec;
43 
48 #ifndef QT_NO_BIG_CODECS
49 #define KVI_NUM_ENCODINGS 112
50 #define KVI_NUM_ENCODING_GROUPS 8
51 #else
52 #define KVI_NUM_ENCODINGS 85
53 #define KVI_NUM_ENCODING_GROUPS 5
54 #endif
55 
61 {
62 public:
68  typedef struct _EncodingDescription
69  {
70  const char * pcName;
71  char bSmart;
72  char bSendUtf8;
73  uint uGroup;
74  const char * pcDescription;
76 
77 protected:
85  KviLocale(QApplication * pApp, const QString & szLocaleDir, const QString & szForceLocaleDir);
86 
91  ~KviLocale();
92 
93 public:
95 
96 protected:
97  QApplication * m_pApp;
98 
99 private:
100  static KviLocale * m_pSelf;
101  static unsigned int m_uCount;
102 
103 public:
111  static void init(QApplication * pApp, const QString & szLocaleDir, const QString & szForceLocaleDir);
112 
118  static void done();
119 
124  static inline KviLocale * instance() { return m_pSelf; }
125 
130  unsigned int count() { return m_uCount; }
131 
139  EncodingDescription * encodingDescription(int iIdx);
140 
148  const char * encodingGroup(int iIdx);
149 
154  const KviCString & localeName() { return g_szLang; }
155 
161  QTextCodec * codecForName(const char * pcName);
162 
176  bool findCatalogue(QString & szBuffer, const QString & szName, const QString & szLocaleDir);
177 
184  KviMessageCatalogue * loadCatalogue(const QString & szName, const QString & szLocaleDir);
185 
191  bool unloadCatalogue(const QString & szName);
192 
198  KviMessageCatalogue * getLoadedCatalogue(const QString & szName);
199 
206  const char * translate(const char * pcText, const char * pcContext);
207 
214  const QString & translateToQString(const char * pcText, const char * pcContext);
215 };
216 
217 #ifndef _KVI_LOCALE_CPP_
219 #endif // !_KVI_LOCALE_CPP_
220 
221 #define __tr(__text__) g_pMainCatalogue->translate(__text__)
222 #define __tr_no_lookup(__text__) __text__
223 #define __tr_no_xgettext(__text__) g_pMainCatalogue->translate(__text__)
224 #define __tr2qs(__text__) g_pMainCatalogue->translateToQString(__text__)
225 #define __tr2qs_no_lookup(__text__) __text__
226 #define __tr2qs_no_xgettext(__text__) g_pMainCatalogue->translateToQString(__text__)
227 
228 #define __tr_ctx(__text__, __context__) KviLocale::instance()->translate(__text__, __context__)
229 #define __tr_no_lookup_ctx(__text__, __context__) __text__
230 #define __tr_no_xgettext_ctx(__text__, __context__) KviLocale::instance()->translate(__text__, __context__)
231 #define __tr2qs_ctx(__text__, __context__) KviLocale::instance()->translateToQString(__text__, __context__)
232 #define __tr2qs_ctx_no_xgettext(__text__, __context__) KviLocale::instance()->translateToQString(__text__, __context__)
233 
234 #endif //_KVI_LOCALE_H_
Definition: KviHeapObject.h:124
Definition: KviCString.h:105
char bSendUtf8
Definition: KviLocale.h:72
static KviLocale * instance()
Returns the instance of the class.
Definition: KviLocale.h:124
QApplication * m_pApp
Definition: KviLocale.h:97
Holds the encoding data.
Definition: KviLocale.h:68
Holds the localization functions.
Definition: KviLocale.h:60
static KviCString g_szLang
Definition: KviLocale.h:94
void done()
Definition: KviKvs.cpp:50
static KviLocale * m_pSelf
Definition: KviLocale.h:100
The KviMessageCatalogue class.
Definition: KviMessageCatalogue.h:47
unsigned int count()
Returns the number of instances of the class.
Definition: KviLocale.h:130
Heap Object.
KVILIB_API KviMessageCatalogue * g_pMainCatalogue
Definition: KviLocale.cpp:48
const char * pcName
Definition: KviLocale.h:70
char bSmart
Definition: KviLocale.h:71
uint uGroup
Definition: KviLocale.h:73
char szBuffer[4096]
Definition: winamp.cpp:77
const KviCString & localeName()
Returns the language code of the localization.
Definition: KviLocale.h:154
int init()
Definition: winamp.cpp:118
This file contains compile time settings.
#define KVILIB_API
Definition: kvi_settings.h:125
const char * pcDescription
Definition: KviLocale.h:74
static unsigned int m_uCount
Definition: KviLocale.h:101