]> git.saurik.com Git - wxWidgets.git/blame - include/wx/intl.h
final (?) changes to the generic tree ctrl -- seems to work ok
[wxWidgets.git] / include / wx / intl.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: intl.h
3// Purpose: Internationalization and localisation for wxWindows
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 29/01/98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __INTLH__
13#define __INTLH__
14
15#ifdef __GNUG__
16#pragma interface "intl.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/string.h"
21
22// ============================================================================
23// global decls
24// ============================================================================
25
26// ----------------------------------------------------------------------------
27// simple types
28// ----------------------------------------------------------------------------
29
30// # adjust if necessary
c86f1403
VZ
31typedef unsigned char size_t8;
32typedef unsigned long size_t32;
c801d85f
KB
33
34// ----------------------------------------------------------------------------
35// macros
36// ----------------------------------------------------------------------------
37
38// gettext() style macro
39#define _(str) wxGetTranslation(str)
40
41// ----------------------------------------------------------------------------
42// forward decls
43// ----------------------------------------------------------------------------
44class WXDLLEXPORT wxLocale;
45class WXDLLEXPORT wxMsgCatalog;
a1530845 46extern WXDLLEXPORT_DATA(wxLocale *) g_pLocale;
c801d85f
KB
47
48// ============================================================================
49// locale support
50// ============================================================================
51
52// ----------------------------------------------------------------------------
53// wxLocale: encapsulates all language dependent settings, including current
54// message catalogs, date, time and currency formats (#### to do) &c
55// ----------------------------------------------------------------------------
56class WXDLLEXPORT wxLocale
57{
58public:
59 // ctor & dtor
23fcecf7
VZ
60 // call Init() if you use this ctor
61 wxLocale();
c801d85f 62 // the ctor has a side effect of changing current locale
a1530845 63 wxLocale(const char *szName, // name (for messages)
c67daf87
UR
64 const char *szShort = (const char *) NULL, // dir prefix (for msg files)
65 const char *szLocale = (const char *) NULL, // locale (for setlocale)
23fcecf7
VZ
66 bool bLoadDefault = TRUE) // preload wxstd.mo?
67 { Init(szName, szShort, szLocale, bLoadDefault); }
68 // the same as a function (returns TRUE on success)
69 bool Init(const char *szName,
c67daf87
UR
70 const char *szShort = (const char *) NULL,
71 const char *szLocale = (const char *) NULL,
23fcecf7 72 bool bLoadDefault = TRUE);
c801d85f
KB
73 // restores old locale
74 ~wxLocale();
75
76 // returns locale name
77 const char *GetLocale() const { return m_strLocale; }
78
79 // add a catalog: it's searched for in standard places (current directory
80 // first, system one after). It will be used for message lookup by
81 // GetString().
82 //
83 // Returns 'true' if it was successfully loaded
84 bool AddCatalog(const char *szDomain);
85
86 // check if the given catalog is loaded
87 bool IsLoaded(const char *szDomain) const;
88
89 // retrieve the translation for a string in all loaded domains unless
90 // the szDomain parameter is specified (and then only this domain is
91 // searched)
92 //
93 // return original string if translation is not available
94 // (in this case an error message is generated the first time
95 // a string is not found; use wxLogNull to suppress it)
96 //
97 // domains are searched in the last to first order, i.e. catalogs
98 // added later override those added before.
99 const char *GetString(const char *szOrigString,
c67daf87 100 const char *szDomain = (const char *) NULL) const;
c801d85f
KB
101
102private:
103 // find catalog by name in a linked list, return NULL if !found
104 wxMsgCatalog *FindCatalog(const char *szDomain) const;
105
106 wxString m_strLocale, // this locale name
107 m_strShort; // short name for the locale
108
109 const char *m_pszOldLocale; // previous locale from setlocale()
110 wxLocale *m_pOldLocale; // previous wxLocale
111
112 wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs
113};
114
9d8046f6 115// ----------------------------------------------------------------------------
a1530845 116// global functions
9d8046f6 117// ----------------------------------------------------------------------------
c740f496 118wxLocale* WXDLLEXPORT wxGetLocale();
9d8046f6
VZ
119
120// get the translation of the string in the current locale
a1530845 121inline WXDLLEXPORT const char *wxGetTranslation(const char *sz)
9d8046f6
VZ
122{
123 wxLocale *pLoc = wxGetLocale();
c67daf87 124 return pLoc == (wxLocale *) NULL ? sz : pLoc->GetString(sz);
9d8046f6
VZ
125}
126
c801d85f 127#endif
34138703 128 // _WX_INTLH__