]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/locale.tex
Added Set/Get/HasOption members and moved palette to ref data class.
[wxWidgets.git] / docs / latex / wx / locale.tex
1 \section{\class{wxLocale}}\label{wxlocale}
2
3 wxLocale class encapsulates all language-dependent settings and is a
4 generalization of the C locale concept.
5
6 In wxWindows this class manages message catalogs which contain the translations
7 of the strings used to the current language.
8
9 \wxheading{Derived from}
10
11 No base class
12
13 \wxheading{See also}
14
15 \helpref{I18n overview}{internationalization}
16
17 \wxheading{Include files}
18
19 <wx/intl.h>
20
21 \latexignore{\rtfignore{\wxheading{Members}}}
22
23 \membersection{wxLocale::wxLocale}\label{wxlocaledefctor}
24
25 \func{}{wxLocale}{\void}
26
27 This is the default constructor and it does nothing to initialize the object:
28 \helpref{Init()}{wxlocaleinit} must be used to do that.
29
30 \func{}{wxLocale}{\param{const char }{*szName}, \param{const char }{*szShort = NULL}, \param{const char }{*szLocale = NULL}, \param{bool }{bLoadDefault = TRUE}, \param{bool }{bConvertEncoding = FALSE}}
31
32 The parameters have the following meaning:
33 \begin{itemize}\itemsep=0pt
34 \item szName is the name of the locale and is only used in diagnostic messages
35 \item szShort is the standard 2 letter locale abbreviation and is used as the
36 directory prefix when looking for the message catalog files
37 \item szLocale is the parameter for the call to setlocale()
38 \item bLoadDefault may be set to FALSE to prevent loading of the message catalog
39 for the given locale containing the translations of standard wxWindows messages.
40 This parameter would be rarely used in normal circumstances.
41 \item bConvertEncoding may be set to TRUE to do automatic conversion of message
42 catalogs to platform's native encoding. Note that it will do only basic
43 conversion between well-known pair like iso8859-1 and windows-1252 or
44 iso8859-2 and windows-1250.
45 See \helpref{Writing non-English applications}{nonenglishoverview} for detailed
46 description of this behaviour.
47 \end{itemize}
48
49 The call of this function has several global side effects which you should
50 understand: first of all, the application locale is changed - note that this
51 will affect many of standard C library functions such as printf() or strftime().
52 Second, this wxLocale object becomes the new current global locale for the
53 application and so all subsequent calls to wxGetTranslation() will try to
54 translate the messages using the message catalogs for this locale.
55
56 \membersection{wxLocale::\destruct{wxLocale}}\label{wxlocaledtor}
57
58 \func{}{\destruct{wxLocale}}{\void}
59
60 The destructor, like the constructor, also has global side effects: the previously
61 set locale is restored and so the changes described in
62 \helpref{Init}{wxlocaleinit} documentation are rolled back.
63
64 \membersection{wxLocale::GetLocale}\label{wxlocalegetlocale}
65
66 \constfunc{const char*}{GetLocale}{\void}
67
68 Returns the locale name as passed to the constructor or
69 \helpref{Init()}{wxlocaleinit}.
70
71 \membersection{wxLocale::AddCatalog}\label{wxlocaleaddcatalog}
72
73 \func{bool}{AddCatalog}{\param{const char }{*szDomain}}
74
75 Add a catalog for use with the current locale: it is searched for in standard
76 places (current directory first, then the system one), but you may also prepend
77 additional directories to the search path with
78 \helpref{AddCatalogLookupPathPrefix()}{wxlocaleaddcataloglookuppathprefix}.
79
80 All loaded catalogs will be used for message lookup by GetString() for the
81 current locale.
82
83 Returns TRUE if catalog was successfully loaded, FALSE otherwise (which might
84 mean that the catalog is not found or that it isn't in the correct format).
85
86 \membersection{wxLocale::AddCatalogLookupPathPrefix}\label{wxlocaleaddcataloglookuppathprefix}
87
88 \func{void}{AddCatalogLookupPathPrefix}{\param{const wxString\& }{prefix}}
89
90 Add a prefix to the catalog lookup path: the message catalog files will be
91 looked up under prefix/<lang>/LC\_MESSAGES, prefix/LC\_MESSAGES and prefix
92 (in this order).
93
94 This only applies to subsequent invocations of AddCatalog()!
95
96 \membersection{wxLocale::Init}\label{wxlocaleinit}
97
98 \func{bool}{Init}{\param{const char }{*szName}, \param{const char }{*szShort = NULL}, \param{const char }{*szLocale = NULL}, \param{bool }{bLoadDefault = TRUE}}
99
100 The parameters have the following meaning:
101
102 \begin{itemize}\itemsep=0pt
103 \item szName is the name of the locale and is only used in diagnostic messages
104 \item szShort is the standard 2 letter locale abbreviation and is used as the
105 directory prefix when looking for the message catalog files
106 \item szLocale is the parameter for the call to setlocale()
107 \item bLoadDefault may be set to FALSE to prevent loading of the message catalog
108 for the given locale containing the translations of standard wxWindows messages.
109 This parameter would be rarely used in normal circumstances.
110 \end{itemize}
111
112 The call of this function has several global side effects which you should
113 understand: first of all, the application locale is changed - note that this
114 will affect many of standard C library functions such as printf() or strftime().
115 Second, this wxLocale object becomes the new current global locale for the
116 application and so all subsequent calls to wxGetTranslation() will try to
117 translate the messages using the message catalogs for this locale.
118
119 Returns TRUE on success or FALSE if the given locale couldn't be set.
120
121 \membersection{wxLocale::IsLoaded}\label{wxlocaleisloaded}
122
123 \constfunc{bool}{IsLoaded}{\param{const char* }{domain}}
124
125 Check if the given catalog is loaded, and returns TRUE if it is.
126
127 According to GNU gettext tradition, each catalog
128 normally corresponds to 'domain' which is more or less the application name.
129
130 See also: \helpref{AddCatalog}{wxlocaleaddcatalog}
131
132 \membersection{wxLocale::GetName}\label{wxlocalegetname}
133
134 \constfunc{const wxString\&}{GetName}{\void}
135
136 Returns the current short name for the locale (as given to the constructor or
137 the Init() function).
138
139 \membersection{wxLocale::GetString}\label{wxlocalegetstring}
140
141 \constfunc{const char*}{GetString}{\param{const char }{*szOrigString}, \param{const char }{*szDomain = NULL}}
142
143 Retrieves the translation for a string in all loaded domains unless the szDomain
144 parameter is specified (and then only this catalog/domain is searched).
145
146 Returns original string if translation is not available
147 (in this case an error message is generated the first time
148 a string is not found; use \helpref{wxLogNull}{wxlogoverview} to suppress it).
149
150 \wxheading{Remarks}
151
152 Domains are searched in the last to first order, i.e. catalogs
153 added later override those added before.
154