File: wx131.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (157 lines) | stat: -rw-r--r-- 7,380 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<HTML>
<head><title>wxLocale</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxlocale"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx130.htm#wxlistevent"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx132.htm#wxlog"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxLocale</H2>
<P>
wxLocale class encapsulates all language-dependent settings and is a
generalization of the C locale concept.<P>
In wxWindows this class manages message catalogs which contain the translations
of the strings used to the current language.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
No base class<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx315.htm#internationalization">I18n overview</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/intl.h&gt;<P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxlocaledefctor">wxLocale::wxLocale</A><BR>
<A HREF="#wxlocaledtor">wxLocale::~wxLocale</A><BR>
<A HREF="#wxlocalegetlocale">wxLocale::GetLocale</A><BR>
<A HREF="#wxlocaleaddcatalog">wxLocale::AddCatalog</A><BR>
<A HREF="#wxlocaleaddcataloglookuppathprefix">wxLocale::AddCatalogLookupPathPrefix</A><BR>
<A HREF="#wxlocaleinit">wxLocale::Init</A><BR>
<A HREF="#wxlocaleisloaded">wxLocale::IsLoaded</A><BR>
<A HREF="#wxlocalegetname">wxLocale::GetName</A><BR>
<A HREF="#wxlocalegetstring">wxLocale::GetString</A><BR>
<P>

<HR>
<A NAME="wxlocaledefctor"></A>
<H3>wxLocale::wxLocale</H3>
<P>
<B></B> <B>wxLocale</B>()<P>
This is the default constructor and it does nothing to initialize the object: 
<A HREF="wx131.htm#wxlocaleinit">Init()</A> must be used to do that.<P>
<B></B> <B>wxLocale</B>(<B>const char </B><I>*szName</I>, <B>const char </B><I>*szShort = NULL</I>, <B>const char </B><I>*szLocale = NULL</I>, <B>bool </B><I>bLoadDefault = TRUE</I>)<P>
The parameters have the following meaning:
<UL>

<LI> szName is the name of the locale and is only used in diagnostic messages
<LI> szShort is the standard 2 letter locale abbreviation and is used as the
directory prefix when looking for the message catalog files
<LI> szLocale is the parameter for the call to setlocale()
<LI> bLoadDefault may be set to FALSE to prevent loading of the message catalog
for the given locale containing the translations of standard wxWindows messages.
This parameter would be rarely used in normal circumstances.
</UL>
<P>
The call of this function has several global side effects which you should
understand: first of all, the application locale is changed - note that this
will affect many of standard C library functions such as printf() or strftime().
Second, this wxLocale object becomes the new current global locale for the
application and so all subsequent calls to wxGetTranslation() will try to
translate the messages using the message catalogs for this locale.<P>

<HR>
<A NAME="wxlocaledtor"></A>
<H3>wxLocale::~wxLocale</H3>
<P>
<B></B> <B>~wxLocale</B>()<P>
The destructor, like the constructor, also has global side effects: the previously
set locale is restored and so the changes described in 
<A HREF="wx131.htm#wxlocaleinit">Init</A> documentation are rolled back.<P>

<HR>
<A NAME="wxlocalegetlocale"></A>
<H3>wxLocale::GetLocale</H3>
<P>
<B>const char*</B> <B>GetLocale</B>() <B>const</B><P>
Returns the locale name as passed to the constructor or 
<A HREF="wx131.htm#wxlocaleinit">Init()</A>.<P>

<HR>
<A NAME="wxlocaleaddcatalog"></A>
<H3>wxLocale::AddCatalog</H3>
<P>
<B>bool</B> <B>AddCatalog</B>(<B>const char </B><I>*szDomain</I>)<P>
Add a catalog for use with the current locale: it's searched for in standard
places (current directory first, then the system one), but you may also prepend
additional directories to the search path with 
<A HREF="wx131.htm#wxlocaleaddcataloglookuppathprefix">AddCatalogLookupPathPrefix()</A>.<P>
All loaded catalogs will be used for message lookup by GetString() for the
current locale.<P>
Returns TRUE if catalog was successfully loaded, FALSE otherwise (which might
mean that the catalog is not found or that it isn't in the correct format).<P>

<HR>
<A NAME="wxlocaleaddcataloglookuppathprefix"></A>
<H3>wxLocale::AddCatalogLookupPathPrefix</H3>
<P>
<B>void</B> <B>AddCatalogLookupPathPrefix</B>(<B>const wxString&amp; </B><I>prefix</I>)<P>
Add a prefix to the catalog lookup path: the message catalog files will be
looked up under prefix/&lt;lang&gt;/LC_MESSAGES, prefix/LC_MESSAGES and prefix
(in this order).<P>
This only applies to subsequent invocations of AddCatalog()!<P>

<HR>
<A NAME="wxlocaleinit"></A>
<H3>wxLocale::Init</H3>
<P>
<B>bool</B> <B>Init</B>(<B>const char </B><I>*szName</I>, <B>const char </B><I>*szShort = NULL</I>, <B>const char </B><I>*szLocale = NULL</I>, <B>bool </B><I>bLoadDefault = TRUE</I>)<P>
The parameters have the following meaning:<P>
<UL>

<LI> szName is the name of the locale and is only used in diagnostic messages
<LI> szShort is the standard 2 letter locale abbreviation and is used as the
directory prefix when looking for the message catalog files
<LI> szLocale is the parameter for the call to setlocale()
<LI> bLoadDefault may be set to FALSE to prevent loading of the message catalog
for the given locale containing the translations of standard wxWindows messages.
This parameter would be rarely used in normal circumstances.
</UL>
<P>
The call of this function has several global side effects which you should
understand: first of all, the application locale is changed - note that this
will affect many of standard C library functions such as printf() or strftime().
Second, this wxLocale object becomes the new current global locale for the
application and so all subsequent calls to wxGetTranslation() will try to
translate the messages using the message catalogs for this locale.<P>
Returns TRUE on success or FALSE if the given locale couldn't be set.<P>

<HR>
<A NAME="wxlocaleisloaded"></A>
<H3>wxLocale::IsLoaded</H3>
<P>
<B>bool</B> <B>IsLoaded</B>(<B>const char* </B><I>domain</I>) <B>const</B><P>
Check if the given catalog is loaded, and returns TRUE if it is.<P>
According to GNU gettext tradition, each catalog
normally corresponds to 'domain' which is more or less the application name.<P>
See also: <A HREF="wx131.htm#wxlocaleaddcatalog">AddCatalog</A><P>

<HR>
<A NAME="wxlocalegetname"></A>
<H3>wxLocale::GetName</H3>
<P>
<B>const wxString&amp;</B> <B>GetName</B>() <B>const</B><P>
Returns the current short name for the locale (as given to the constructor or
the Init() function).<P>

<HR>
<A NAME="wxlocalegetstring"></A>
<H3>wxLocale::GetString</H3>
<P>
<B>const char*</B> <B>GetString</B>(<B>const char </B><I>*szOrigString</I>, <B>const char </B><I>*szDomain = NULL</I>) <B>const</B><P>
Retrieves the translation for a string in all loaded domains unless the szDomain
parameter is specified (and then only this catalog/domain is searched).<P>
Returns original string if translation is not available
(in this case an error message is generated the first time
a string is not found; use <A HREF="wx282.htm#wxlogoverview">wxLogNull</A> to suppress it).<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
Domains are searched in the last to first order, i.e. catalogs
added later override those added before.<P>

</BODY></HTML>