1 \section{\class{wxLocale
}}\label{wxlocale
}
3 wxLocale class encapsulates all language-dependent settings and is a
4 generalization of the C locale concept.
6 In wxWindows this class manages message catalogs which contain the translations
7 of the strings used to the current language.
9 \wxheading{Derived from
}
15 \helpref{I18n overview
}{internationalization
}
17 \wxheading{Include files
}
21 \latexignore{\rtfignore{\wxheading{Members
}}}
23 \membersection{wxLocale::wxLocale
}\label{wxlocaledefctor
}
25 \func{}{wxLocale
}{\void}
27 This is the default constructor and it does nothing to initialize the object:
28 \helpref{Init()
}{wxlocaleinit
} must be used to do that.
30 \func{}{wxLocale
}{\param{const char
}{*szName
},
\param{const char
}{*szShort = NULL
},
\param{const char
}{*szLocale = NULL
},
\param{bool
}{bLoadDefault = TRUE
}}
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.
43 The call of this function has several global side effects which you should
44 understand: first of all, the application locale is changed - note that this
45 will affect many of standard C library functions such as printf() or strftime().
46 Second, this wxLocale object becomes the new current global locale for the
47 application and so all subsequent calls to wxGetTranslation() will try to
48 translate the messages using the message catalogs for this locale.
50 \membersection{wxLocale::
\destruct{wxLocale
}}\label{wxlocaledtor
}
52 \func{}{\destruct{wxLocale
}}{\void}
54 The destructor, like the constructor, also has global side effects: the previously
55 set locale is restored and so the changes described in
56 \helpref{Init
}{wxlocaleinit
} documentation are rolled back.
58 \membersection{wxLocale::GetLocale
}\label{wxlocalegetlocale
}
60 \constfunc{const char*
}{GetLocale
}{\void}
62 Returns the locale name as passed to the constructor or
63 \helpref{Init()
}{wxlocaleinit
}.
65 \membersection{wxLocale::AddCatalog
}\label{wxlocaleaddcatalog
}
67 \func{bool
}{AddCatalog
}{\param{const char
}{*szDomain
}}
69 Add a catalog for use with the current locale: it's searched for in standard
70 places (current directory first, then the system one), but you may also prepend
71 additional directories to the search path with
72 \helpref{AddCatalogLookupPathPrefix()
}{wxlocaleaddcataloglookuppathprefix
}.
74 All loaded catalogs will be used for message lookup by GetString() for the
77 Returns TRUE if catalog was successfully loaded, FALSE otherwise (which might
78 mean that the catalog is not found or that it isn't in the correct format).
80 \membersection{wxLocale::AddCatalogLookupPathPrefix
}\label{wxlocaleaddcataloglookuppathprefix
}
82 \func{void
}{AddCatalogLookupPathPrefix
}{\param{const wxString\&
}{prefix
}}
84 Add a prefix to the catalog lookup path: the message catalog files will be
85 looked up under prefix/<lang>/LC
\_MESSAGES, prefix/LC
\_MESSAGES and prefix
88 This only applies to subsequent invocations of AddCatalog()!
90 \membersection{wxLocale::Init
}\label{wxlocaleinit
}
92 \func{bool
}{Init
}{\param{const char
}{*szName
},
\param{const char
}{*szShort = NULL
},
\param{const char
}{*szLocale = NULL
},
\param{bool
}{bLoadDefault = TRUE
}}
94 The parameters have the following meaning:
96 \begin{itemize
}\itemsep=
0pt
97 \item szName is the name of the locale and is only used in diagnostic messages
98 \item szShort is the standard
2 letter locale abbreviation and is used as the
99 directory prefix when looking for the message catalog files
100 \item szLocale is the parameter for the call to setlocale()
101 \item bLoadDefault may be set to FALSE to prevent loading of the message catalog
102 for the given locale containing the translations of standard wxWindows messages.
103 This parameter would be rarely used in normal circumstances.
106 The call of this function has several global side effects which you should
107 understand: first of all, the application locale is changed - note that this
108 will affect many of standard C library functions such as printf() or strftime().
109 Second, this wxLocale object becomes the new current global locale for the
110 application and so all subsequent calls to wxGetTranslation() will try to
111 translate the messages using the message catalogs for this locale.
113 Returns TRUE on success or FALSE if the given locale couldn't be set.
115 \membersection{wxLocale::IsLoaded
}\label{wxlocaleisloaded
}
117 \constfunc{bool
}{IsLoaded
}{\param{const char*
}{domain
}}
119 Check if the given catalog is loaded, and returns TRUE if it is.
121 According to GNU gettext tradition, each catalog
122 normally corresponds to 'domain' which is more or less the application name.
124 See also:
\helpref{AddCatalog
}{wxlocaleaddcatalog
}
126 \membersection{wxLocale::GetName
}\label{wxlocalegetname
}
128 \constfunc{const wxString\&
}{GetName
}{\void}
130 Returns the current short name for the locale (as given to the constructor or
131 the Init() function).
133 \membersection{wxLocale::GetString
}\label{wxlocalegetstring
}
135 \constfunc{const char*
}{GetString
}{\param{const char
}{*szOrigString
},
\param{const char
}{*szDomain = NULL
}}
137 Retrieves the translation for a string in all loaded domains unless the szDomain
138 parameter is specified (and then only this catalog/domain is searched).
140 Returns original string if translation is not available
141 (in this case an error message is generated the first time
142 a string is not found; use
\helpref{wxLogNull
}{wxlogoverview
} to suppress it).
146 Domains are searched in the last to first order, i.e. catalogs
147 added later override those added before.