/////////////////////////////////////////////////////////////////////////////
// Name: intl.h
-// Purpose: documentation for wxLocale class
+// Purpose: interface of wxLocale
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
@library{wxbase}
@category{FIXME}
- @seealso
- @ref overview_internationalization "Internationalization overview", @ref
- overview_sampleinternat "Internat sample", wxXLocale
+ @see @ref overview_internationalization, @ref overview_sampleinternat "Internat
+ sample", wxXLocale
*/
class wxLocale
{
//@{
/**
See Init() for parameters description.
-
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().
wxLocale(const wxString& name,
const wxString& short = wxEmptyString,
const wxString& locale = wxEmptyString,
- bool bLoadDefault = @true,
- bool bConvertEncoding = @false);
+ bool bLoadDefault = true,
+ bool bConvertEncoding = false);
//@}
/**
places (current directory first, then the system one), but you may also prepend
additional directories to the search path with
AddCatalogLookupPathPrefix().
-
All loaded catalogs will be used for message lookup by
GetString() for the current locale.
-
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).
-
The second form of this method takes two additional arguments,
- @e msgIdLanguage and @e msgIdCharset.
-
- @e msgIdLanguage specifies the language of "msgid" strings in source code
+ @a msgIdLanguage and @e msgIdCharset.
+ @a msgIdLanguage specifies the language of "msgid" strings in source code
(i.e. arguments to GetString(),
- wxGetTranslation and the
- _ macro). It is used if AddCatalog cannot find any
+ wxGetTranslation() and the
+ _() macro). It is used if AddCatalog cannot find any
catalog for current language: if the language is same as source code language,
then strings from source code are used instead.
-
- @e msgIdCharset lets you specify the charset used for msgids in sources
+ @a msgIdCharset lets you specify the charset used for msgids in sources
in case they use 8-bit characters (e.g. German or French strings). This
argument has no effect in Unicode build, because literals in sources are
Unicode strings; you have to use compiler-specific method of setting the right
charset when compiling with Unicode.
-
By default (i.e. when you use the first form), msgid strings are assumed
to be in English and written only using 7-bit ASCII characters.
-
If you have to deal with non-English strings or 8-bit characters in the source
code, see the instructions in
@ref overview_nonenglishoverview "Writing non-English applications".
Add a prefix to the catalog lookup path: the message catalog files will be
looked up under prefix/lang/LC_MESSAGES, prefix/lang and prefix
(in this order).
-
This only applies to subsequent invocations of AddCatalog().
*/
void AddCatalogLookupPathPrefix(const wxString& prefix);
Adds custom, user-defined language to the database of known languages. This
database is used in conjunction with the first form of
Init().
-
wxLanguageInfo is defined as follows:
-
@e Language should be greater than wxLANGUAGE_USER_DEFINED.
-
Wx::LanguageInfo-new( language, canonicalName, WinLang, WinSubLang, Description
)
*/
given locale, specified either as a two letter ISO language code (for example,
"pt"), a language code followed by the country code ("pt_BR") or a full, human
readable, language description ("Portuguese-Brazil").
-
Returns the information for the given language or @NULL if this language
is unknown. Note that even if the returned pointer is valid, the caller should
@e not delete it.
-
- @sa GetLanguageInfo()
+
+ @see GetLanguageInfo()
*/
- static wxLanguageInfo * FindLanguageInfo(const wxString& locale);
+ static wxLanguageInfo* FindLanguageInfo(const wxString& locale);
/**
Returns the canonical form of current locale name. Canonical form is the
one that is used on UNIX systems: it is a two- or five-letter string in xx or
xx_YY format, where xx is ISO 639 code of language and YY is ISO 3166 code of
the country. Examples are "en", "en_GB", "en_US" or "fr_FR".
-
This form is internally used when looking up message catalogs.
-
Compare GetSysName().
*/
- wxString GetCanonicalName();
+ wxString GetCanonicalName() const;
/**
- Returns the header value for header @e header. The search for @e header is case
+ Returns the header value for header @e header. The search for @a header is case
sensitive. If an @e domain
is passed, this domain is searched. Else all domains will be searched until a
header has been found.
The return value is the value of the header if found. Else this will be empty.
*/
wxString GetHeaderValue(const wxString& header,
- const wxString& domain = wxEmptyString);
+ const wxString& domain = wxEmptyString) const;
/**
- Returns wxLanguage constant of current language.
+ Returns wxLanguage() constant of current language.
Note that you can call this function only if you used the form of
Init() that takes wxLanguage argument.
*/
- int GetLanguage();
+ int GetLanguage() const;
/**
Returns a pointer to wxLanguageInfo structure containing information about the
given language or @NULL if this language is unknown. Note that even if the
returned pointer is valid, the caller should @e not delete it.
-
See AddLanguage() for the wxLanguageInfo
description.
-
As with Init(), @c wxLANGUAGE_DEFAULT has the
special meaning if passed as an argument to this function and in this case the
result of GetSystemLanguage() is used.
*/
- static wxLanguageInfo * GetLanguageInfo(int lang);
+ static wxLanguageInfo* GetLanguageInfo(int lang) const;
/**
Returns English name of the given language or empty string if this
language is unknown.
-
See GetLanguageInfo() for a remark about
special meaning of @c wxLANGUAGE_DEFAULT.
*/
- static wxString GetLanguageName(int lang);
+ static wxString GetLanguageName(int lang) const;
/**
Returns the locale name as passed to the constructor or
Init(). This is full, human-readable name,
e.g. "English" or "French".
*/
- const wxString GetLocale();
+ const wxString GetLocale() const;
/**
Returns the current short name for the locale (as given to the constructor or
the Init() function).
*/
- const wxString GetName();
+ const wxString GetName() const;
//@{
/**
Retrieves the translation for a string in all loaded domains unless the szDomain
parameter is specified (and then only this catalog/domain is searched).
-
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 wxLogNull to suppress it).
-
The second form is used when retrieving translation of string that has
different singular and plural form in English or different plural forms in some
other language. It takes two extra arguments: @e origString
parameter must contain the singular form of the string to be converted.
It is also used as the key for the search in the catalog.
- The @e origString2 parameter is the plural form (in English).
- The parameter @e n is used to determine the plural form. If no
- message catalog is found @e origString is returned if 'n == 1',
+ The @a origString2 parameter is the plural form (in English).
+ The parameter @a n is used to determine the plural form. If no
+ message catalog is found @a origString is returned if 'n == 1',
otherwise @e origString2.
See GNU gettext manual for additional information on plural forms handling.
-
- This method is called by the wxGetTranslation
- function and _ macro.
-
+ This method is called by the wxGetTranslation()
+ function and _() macro.
+
@remarks Domains are searched in the last to first order, i.e. catalogs
- added later override those added before.
+ added later override those added before.
*/
const wxString GetString(const wxString& origString,
- const wxString& domain = wxEmptyString);
- const wxString GetString(const wxString& origString,
- const wxString& origString2,
- size_t n,
- const wxString& domain = @NULL);
+ const wxString& domain = wxEmptyString) const;
+ const const wxString& GetString(const wxString& origString,
+ const wxString& origString2,
+ size_t n,
+ const wxString& domain = NULL) const;
//@}
/**
Returns current platform-specific locale name as passed to setlocale().
-
Compare GetCanonicalName().
*/
- wxString GetSysName();
+ wxString GetSysName() const;
/**
Tries to detect the user's default font encoding.
- Returns wxFontEncoding value or
+ Returns wxFontEncoding() value or
@b wxFONTENCODING_SYSTEM if it couldn't be determined.
*/
- static wxFontEncoding GetSystemEncoding();
+ static wxFontEncoding GetSystemEncoding() const;
/**
Tries to detect the name of the user's default font encoding. This string isn't
particularly useful for the application as its form is platform-dependent and
so you should probably use
GetSystemEncoding() instead.
-
Returns a user-readable string value or an empty string if it couldn't be
determined.
*/
- static wxString GetSystemEncodingName();
+ static wxString GetSystemEncodingName() const;
/**
Tries to detect the user's default language setting.
- Returns wxLanguage value or
+ Returns wxLanguage() value or
@b wxLANGUAGE_UNKNOWN if the language-guessing algorithm failed.
*/
- static int GetSystemLanguage();
+ static int GetSystemLanguage() const;
//@{
/**
The second form is deprecated, use the first one unless you know what you are
doing.
-
+
@param language
- wxLanguage identifier of the locale.
- wxLANGUAGE_DEFAULT has special meaning -- wxLocale will use system's default
- language (see GetSystemLanguage).
-
+ wxLanguage identifier of the locale.
+ wxLANGUAGE_DEFAULT has special meaning -- wxLocale will use system's
+ default
+ language (see GetSystemLanguage).
@param flags
- Combination of the following:
-
-
- wxLOCALE_LOAD_DEFAULT
-
-
- Load the message catalog
- for the given locale containing the translations of standard wxWidgets messages
- automatically.
-
- wxLOCALE_CONV_ENCODING
-
-
- Automatically convert message
- catalogs to platform's default encoding. Note that it will do only basic
- conversion between well-known pair like iso8859-1 and windows-1252 or
- iso8859-2 and windows-1250. See Writing non-English applications for detailed
- description of this behaviour. Note that this flag is meaningless in Unicode
- build.
-
+ Combination of the following:
+
+
+
+
+
+
+
+ wxLOCALE_LOAD_DEFAULT
+
+
+
+
+ Load the message catalog
+ for the given locale containing the translations of standard wxWidgets
+ messages
+ automatically.
+
+
+
+
+
+ wxLOCALE_CONV_ENCODING
+
+
+
+
+ Automatically convert message
+ catalogs to platform's default encoding. Note that it will do only basic
+ conversion between well-known pair like iso8859-1 and windows-1252 or
+ iso8859-2 and windows-1250. See Writing non-English applications for
+ detailed
+ description of this behaviour. Note that this flag is meaningless in
+ Unicode build.
@param name
- The name of the locale. Only used in diagnostic messages.
-
+ The name of the locale. Only used in diagnostic messages.
@param short
- The standard 2 letter locale abbreviation; it is used as the
- directory prefix when looking for the message catalog files.
-
+ The standard 2 letter locale abbreviation; it is used as the
+ directory prefix when looking for the message catalog files.
@param locale
- The parameter for the call to setlocale(). Note that it is
- platform-specific.
-
+ The parameter for the call to setlocale(). Note that it is
+ platform-specific.
@param bLoadDefault
- May be set to @false to prevent loading of the message catalog
- for the given locale containing the translations of standard wxWidgets messages.
- This parameter would be rarely used in normal circumstances.
-
+ May be set to @false to prevent loading of the message catalog
+ for the given locale containing the translations of standard wxWidgets
+ messages.
+ This parameter would be rarely used in normal circumstances.
@param bConvertEncoding
- May be set to @true to do automatic conversion of message
- catalogs to platform's native encoding. Note that it will do only basic
- conversion between well-known pair like iso8859-1 and windows-1252 or
- iso8859-2 and windows-1250.
- See Writing non-English applications for detailed
- description of this behaviour.
+ May be set to @true to do automatic conversion of message
+ catalogs to platform's native encoding. Note that it will do only basic
+ conversion between well-known pair like iso8859-1 and windows-1252 or
+ iso8859-2 and windows-1250.
+ See Writing non-English applications for detailed
+ description of this behaviour.
*/
bool Init(int language = wxLANGUAGE_DEFAULT,
int flags =
bool Init(const wxString& name,
const wxString& short = wxEmptyString,
const wxString& locale = wxEmptyString,
- bool bLoadDefault = @true,
- bool bConvertEncoding = @false);
+ bool bLoadDefault = true,
+ bool bConvertEncoding = false);
//@}
/**
this locale. For example in Windows 2000 and Windows XP, support for many
locales is not installed by default. Returns @true if the locale is
supported.
-
- The argument @e lang is the wxLanguage identifier. To obtain this for a
+ The argument @a lang is the wxLanguage identifier. To obtain this for a
given a two letter ISO language code, use
FindLanguageInfo() to obtain its
wxLanguageInfo structure. See AddLanguage() for
the wxLanguageInfo description.
-
- This function is new since wxWidgets version 2.7.1.
+
+ @wxsince{2.7.1}.
*/
static bool IsAvailable(int lang);
/**
Check if the given catalog is loaded, and returns @true if it is.
-
According to GNU gettext tradition, each catalog
normally corresponds to 'domain' which is more or less the application name.
-
See also: AddCatalog()
*/
- bool IsLoaded(const char* domain);
+ bool IsLoaded(const char* domain) const;
/**
Returns @true if the locale could be set successfully.
*/
-#define bool IsOk() /* implementation is private */
+ bool IsOk() const;
/**
See @ref overview_languagecodes "list of recognized language constants".
};
+
/**
@class wxXLocale
@wxheader{intl.h}
@library{wxbase}
@category{FIXME}
- @seealso
- wxLocale
+ @see wxLocale
*/
class wxXLocale
{
*/
wxLocale();
wxLocale(wxLanguage lang);
- wxLocale(const char * loc);
+ wxLocale(const char* loc);
//@}
/**
most of the recent Unix systems (including Linux, various BSD and Mac OS X) and
Microsoft Visual C++ standard library provides a similar API starting from
version 8 (Visual Studio 2005).
-
If neither POSIX API nor Microsoft proprietary equivalent are available, this
class is still available but works in degraded mode: the only supported locale
is the C one and attempts to create wxXLocale object for any other locale will
fail. You can use the preprocessor macro @c wxHAS_XLOCALE_SUPPORT to
test if full xlocale API is available or only skeleton C locale support is
present.
-
Notice that wxXLocale is new in wxWidgets 2.9.0 and is not compiled in if
@c wxUSE_XLOCALE was set to 0 during the library compilation.
*/
or
@false otherwise.
*/
-#define bool IsOk() /* implementation is private */
+ bool IsOk() const;
/**
Currently the following @c _l-functions are available:
-
Character classification functions: @c wxIsxxx_l(), e.g.
@c wxIsalpha_l(), @c wxIslower_l() and all the others.
Character transformation functions: @c wxTolower_l() and
@c wxToupper_l()
-
We hope to provide many more functions (covering numbers, time and formatted
IO) in the near future.
-
- @sa wxLocale
+
+ @see wxLocale
*/
};
+
// ============================================================================
// Global functions/macros
// ============================================================================
/**
- This macro is identical to _ but for the plural variant
- of wxGetTranslation.
+ This macro is identical to _() but for the plural variant
+ of wxGetTranslation().
*/
#define const wxString wxPLURAL(const wxString& sing,
const wxString& plur,
/**
This macro doesn't do anything in the program code -- it simply expands to the
value of its argument.
-
However it does have a purpose which is to mark the literal strings for the
extraction into the message catalog created by @c xgettext program. Usually
- this is achieved using _ but that macro not only marks
+ this is achieved using _() but that macro not only marks
the string for extraction but also expands into a
- wxGetTranslation function call which means that it
+ wxGetTranslation() function call which means that it
cannot be used in some situations, notably for static array
initialization.
-
Here is an example which should make it more clear: suppose that you have a
static array of strings containing the weekday names and which have to be
translated (note that it is a bad example, really, as
wxDateTime already can be used to get the localized week
day names already). If you write
+
@code
static const char * const weekdays[] = { _("Mon"), ..., _("Sun") };
...
the code wouldn't compile because the function calls are forbidden in the array
initializer. So instead you should do
+
@code
static const char * const weekdays[] = { wxTRANSLATE("Mon"), ...,
wxTRANSLATE("Sun") };
@endcode
here.
-
Note that although the code @b would compile if you simply omit
wxTRANSLATE() in the above, it wouldn't work as expected because there would be
no translations for the weekday names in the program message catalog and
wxGetTranslation wouldn't find them.
*/
-#define const wxChar * wxTRANSLATE(const char * s) /* implementation is private */
+#define const wxChar* wxTRANSLATE(const char* s) /* implementation is private */
/**
- This macro expands into a call to wxGetTranslation
+ This macro expands into a call to wxGetTranslation()
function, so it marks the message for the extraction by @c xgettext just as
- wxTRANSLATE does, but also returns the translation of
+ wxTRANSLATE() does, but also returns the translation of
the string for the current locale during execution.
-
- Don't confuse this macro with _T!
+ Don't confuse this macro with _T()!
*/
-#define const wxString _(const wxString& s) /* implementation is private */
+const wxString _(const wxString& s);
//@{
/**
- This function returns the translation of string @e str in the current
- locale. If the string is not found in any of the loaded
+ This function returns the translation of string @a str in the current
+ locale(). If the string is not found in any of the loaded
message catalogs (see @ref overview_internationalization "internationalization
overview"), the
original string is returned. In debug build, an error message is logged -- this
should help to find the strings which were not yet translated. If
- @e domain is specified then only that domain/catalog is searched
+ @a domain is specified then only that domain/catalog is searched
for a matching string. As this function
is used very often, an alternative (and also common in Unix world) syntax is
- provided: the _ macro is defined to do the same thing
+ provided: the _() macro is defined to do the same thing
as wxGetTranslation.
-
The second form is used when retrieving translation of string that has
different singular and plural form in English or different plural forms in some
other language. It takes two extra arguments: as above, @e str
parameter must contain the singular form of the string to be converted and
- is used as the key for the search in the catalog. The @e strPlural parameter
- is the plural form (in English). The parameter @e n is used to determine the
- plural form. If no message catalog is found @e str is returned if 'n == 1',
+ is used as the key for the search in the catalog. The @a strPlural parameter
+ is the plural form (in English). The parameter @a n is used to determine the
+ plural form. If no message catalog is found @a str is returned if 'n == 1',
otherwise @e strPlural.
-
See GNU gettext manual
for additional information on plural forms handling. For a shorter alternative
- see the wxPLURAL macro.
-
+ see the wxPLURAL() macro.
Both versions call wxLocale::GetString.
-
Note that this function is not suitable for literal strings in Unicode
builds, since the literal strings must be enclosed into
- _T or wxT macro which makes them
+ _T() or wxT() macro which makes them
unrecognised by @c xgettext, and so they are not extracted to the message
- catalog. Instead, use the _ and
- wxPLURAL macro for all literal strings.
+ catalog. Instead, use the _() and
+ wxPLURAL() macro for all literal strings.
*/
const wxString wxGetTranslation(const wxString& str,
const wxString& domain = wxEmptyString);