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