Inheritance diagram for wx.Locale:
wx.Locale class encapsulates all language-dependent settings and is a generalization of the C locale concept.
In wxWidgets this class manages message catalogs which contain the translations of the strings used to the current language.
Constructor.
Parameters:
Returns:
Add a catalog for use with the current locale: it is searched for in standard 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).
By default msgid strings are assumed to be in English and written only using 7-bit ASCII characters.
Parameters:
Returns:
bool
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().
Parameters:
Adds custom, user-defined language to the database of known languages.
Parameters:
This function may be used to find the language description structure for the 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 None if this language is unknown.
Parameters:
Returns:
wx.LanguageInfo
Note
Note that even if the returned pointer is valid, the caller should not delete it.
See also
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.
Returns:
string
See also
Returns wx.Language constant of current language.
Returns:
int
Returns a pointer to wx.LanguageInfo structure containing information about the given language or None if this language is unknown.
Parameters:
Returns:
wx.LanguageInfo
Note
Note that even if the returned pointer is valid, the caller should not delete it.
Returns English name of the given language or empty string if this language is unknown.
Parameters:
Returns:
string
Returns the locale name as passed to the constructor. This is full, human-readable name, e.g. “English” or “French”.
Returns:
string
Returns the current short name for the locale (as given to the constructor or the Init() function).
Returns:
string
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 wx.LogNull to suppress it).
This method is called by the wx.GetTranslation function and _ macro.
Parameters:
Returns:
string
Note
Domains are searched in the last to first order, i.e. catalogs added later override those added before.
Returns current platform-specific locale name as passed to setlocale().
Returns:
string
See also
Tries to detect the user’s default font encoding. Returns wx.FontEncoding value or wx.FONTENCODING_SYSTEM if it couldn’t be determined.
Returns:
int
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.
Returns:
string
Tries to detect the user’s default language setting. Returns wx.Language value or wx.LANGUAGE_UNKNOWN if the language-guessing algorithm failed.
Returns:
int
Parameters:
language (int): identifier of the locale. wx.LANGUAGE_DEFAULT has special meaning – wx.Locale will use system’s default language (see GetSystemLanguage).
flags (int): Combination of the following:
Locale Flags |
Description |
---|---|
wx.LOCALE_LOAD_DEFAULT |
Load the message catalog for the given locale containing the translations of standard wxWidgets messages automatically. |
wx.LOCALE_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. Note that this flag is meaningless in Unicode build. |
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 wx.Locale object becomes the new current global locale for the application and so all subsequent calls to wx.GetTranslation() will try to translate the messages using the message catalogs for this locale.
Returns True on success or False if the given locale couldn’t be set.
Returns:
bool
Parameters:
szName (string): The name of the locale. Only used in diagnostic messages.
szShort (string): The standard 2 letter locale abbreviation; it is used as the directory prefix when looking for the message catalog files.
szLocale (string): The parameter for the call to setlocale().
Note
Note that it is platform-specific.
bLoadDefault (bool): 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.
bConvertEncoding (bool): May be set to True to do automatic conversion of message catalogs to platform’s native encoding.
Note
Note that it will do only basic conversion between well-known pair like iso8859-1 and windows-1252 or iso8859-2 and windows-1250.
Returns:
bool
See also
Parameters:
language (int): identifier of the locale. wx.LANGUAGE_DEFAULT has special meaning – wx.Locale will use system’s default language (see GetSystemLanguage).
flags (int): Combination of the following:
Locale Flags |
Description |
---|---|
wx.LOCALE_LOAD_DEFAULT |
Load the message catalog for the given locale containing the translations of standard wxWidgets messages automatically. |
wx.LOCALE_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. Note that this flag is meaningless in Unicode build. |
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 wx.Locale object becomes the new current global locale for the application and so all subsequent calls to wx.GetTranslation() will try to translate the messages using the message catalogs for this locale.
Returns True on success or False if the given locale couldn’t be set.
Returns:
bool
See also
Check whether the operating system and/or C run time environment supports 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 lang is the wx.Language identifier. To obtain this for a given a two letter ISO language code, use FindLanguageInfo to obtain its wx.LanguageInfo structure.
This function is new since wxWidgets version 2.7.1.
Parameters:
Returns:
bool
See also
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.
Parameters:
Returns:
bool
See also
Returns True if the locale could be set successfully.
Returns:
bool