wx.Locale class encapsulates all language-dependent settings and is a generalization of the C locale concept.
In wxWidgets this class manages current locale. It also initializes and activates wx.Translations object that manages message catalogs.
For a list of the supported languages, please see wx.Language enum values. These constants may be used to specify the language in wx.Locale.Init
and are returned by wx.Locale.GetSystemLanguage
.
__init__ |
This is the default constructor and it does nothing to initialize the object: Init must be used to do that. |
AddCatalog |
Calls wx.Translations.AddCatalog . |
AddCatalogLookupPathPrefix |
Calls wx.FileTranslationsLoader.AddCatalogLookupPathPrefix . |
AddLanguage |
Adds custom, user-defined language to the database of known languages. |
FindLanguageInfo |
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”). |
GetCanonicalName |
Returns the canonical form of current locale name. |
GetHeaderValue |
Calls wx.Translations.GetHeaderValue . |
GetInfo |
Get the values of the given locale-dependent datum. |
GetLanguage |
Returns the wx.Language constant of current language. |
GetLanguageCanonicalName |
Returns canonical name (see GetCanonicalName ) of the given language or empty string if this language is unknown. |
GetLanguageInfo |
Returns a pointer to wx.LanguageInfo structure containing information about the given language or None if this language is unknown. |
GetLanguageName |
Returns English name of the given language or empty string if this language is unknown. |
GetLocale |
Returns the locale name as passed to the constructor or Init . |
GetName |
Returns the current short name for the locale (as given to the constructor or the Init function). |
GetString |
Calls wx.GetTranslation . |
GetSysName |
Returns current platform-specific locale name as passed to setlocale(). |
GetSystemEncoding |
Tries to detect the user’s default font encoding. |
GetSystemEncodingName |
Tries to detect the name of the user’s default font encoding. |
GetSystemLanguage |
Tries to detect the user’s default locale setting. |
Init |
Initializes the wx.Locale instance. |
IsAvailable |
Check whether the operating system and/or C run time environment supports this locale. |
IsLoaded |
Calls wx.Translations.IsLoaded . |
IsOk |
Returns True if the locale could be set successfully. |
__nonzero__ |
CanonicalName |
See GetCanonicalName |
Language |
See GetLanguage |
Locale |
See GetLocale |
Name |
See GetName |
SysName |
See GetSysName |
wx.
Locale
(object)¶Possible constructors:
Locale()
Locale(language, flags=LOCALE_LOAD_DEFAULT)
Locale(name, shortName="", locale="",
bLoadDefault=True)
Locale class encapsulates all language-dependent settings and is a generalization of the C locale concept.
__init__
(self, *args, **kw)¶__init__ (self)
This is the default constructor and it does nothing to initialize the object: Init
must be used to do that.
__init__ (self, language, flags=LOCALE_LOAD_DEFAULT)
See Init
for parameters description.
Parameters: |
|
---|
__init__ (self, name, shortName=””, locale=””, bLoadDefault=True)
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(). 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.
Parameters: |
|
---|
AddCatalog
(self, *args, **kw)¶Calls wx.Translations.AddCatalog
.
AddCatalog (self, domain)
Parameters: | domain (string) – |
---|---|
Return type: | bool |
AddCatalog (self, domain, msgIdLanguage)
Parameters: |
|
---|---|
Return type: | bool |
AddCatalog (self, domain, msgIdLanguage, msgIdCharset)
Parameters: |
|
---|---|
Return type: | bool |
AddCatalogLookupPathPrefix
(prefix)¶Calls wx.FileTranslationsLoader.AddCatalogLookupPathPrefix
.
Parameters: | prefix (string) – |
---|
AddLanguage
(info)¶Adds custom, user-defined language to the database of known languages.
This database is used in conjunction with the first form of Init
.
Parameters: | info (wx.LanguageInfo) – |
---|
FindLanguageInfo
(locale)¶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. Note that even if the returned pointer is valid, the caller should not delete it.
Parameters: | locale (string) – |
---|---|
Return type: | wx.LanguageInfo |
See also
GetCanonicalName
(self)¶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
.
Return type: | string |
---|
GetHeaderValue
(self, header, domain="")¶Calls wx.Translations.GetHeaderValue
.
Parameters: |
|
---|---|
Return type: |
|
GetInfo
(index, cat=LOCALE_CAT_DEFAULT)¶Get the values of the given locale-dependent datum.
This function returns the value of the locale-specific option specified by the given index.
Parameters: |
|
---|---|
Return type: |
|
Returns: | The option value or empty string if the function failed. |
GetLanguage
(self)¶Returns the wx.Language constant of current language.
Note that you can call this function only if you used the form of Init
that takes wx.Language argument.
Return type: | int |
---|
GetLanguageCanonicalName
(lang)¶Returns canonical name (see GetCanonicalName
) of the given language or empty string if this language is unknown.
See GetLanguageInfo
for a remark about special meaning of LANGUAGE_DEFAULT
.
Parameters: | lang (int) – |
---|---|
Return type: | string |
New in version 2.9.1.
GetLanguageInfo
(lang)¶Returns a pointer to wx.LanguageInfo structure containing information about the given language or None
if this language is unknown.
Note that even if the returned pointer is valid, the caller should not delete it.
See AddLanguage
for the wx.LanguageInfo description. As with Init
, LANGUAGE_DEFAULT
has the special meaning if passed as an argument to this function and in this case the result of GetSystemLanguage
is used.
Parameters: | lang (int) – |
---|---|
Return type: | wx.LanguageInfo |
GetLanguageName
(lang)¶Returns English name of the given language or empty string if this language is unknown.
See GetLanguageInfo
for a remark about special meaning of LANGUAGE_DEFAULT
.
Parameters: | lang (int) – |
---|---|
Return type: | string |
GetLocale
(self)¶Returns the locale name as passed to the constructor or Init
.
This is a full, human-readable name, e.g. “English” or “French”.
Return type: | string |
---|
GetName
(self)¶Returns the current short name for the locale (as given to the constructor or the Init
function).
Return type: | string |
---|
GetString
(self, *args, **kw)¶Calls wx.GetTranslation
.
GetString (self, origString, domain=””)
Parameters: |
|
---|---|
Return type: |
|
GetString (self, origString, origString2, n, domain=””)
Parameters: |
|
---|---|
Return type: |
|
GetSysName
(self)¶Returns current platform-specific locale name as passed to setlocale().
Compare GetCanonicalName
.
Return type: | string |
---|
GetSystemEncoding
()¶Tries to detect the user’s default font encoding.
Returns wx.FontEncoding value or FONTENCODING_SYSTEM
if it couldn’t be determined.
Return type: | wx.FontEncoding |
---|
GetSystemEncodingName
()¶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.
Return type: | string |
---|
GetSystemLanguage
()¶Tries to detect the user’s default locale setting.
Returns the wx.Language value or LANGUAGE_UNKNOWN
if the language-guessing algorithm failed.
Return type: | int |
---|
Note
This function works with locales and returns the user’s default locale. This may be, and usually is, the same as their preferred UI language, but it’s not the same thing. Use Translation to obtain language information.
See also
Init
(self, *args, **kw)¶Init (self, language=LANGUAGE_DEFAULT, flags=LOCALE_LOAD_DEFAULT)
Initializes the wx.Locale instance.
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.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
Init (self, name, shortName=””, locale=””, bLoadDefault=True)
Parameters: |
|
---|---|
Return type: | bool |
Deprecated since version 4.0.0: This form is deprecated, use the other one unless you know what you are doing.
IsAvailable
(lang)¶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. See AddLanguage
for the wx.LanguageInfo description.
Parameters: | lang (int) – |
---|---|
Return type: | bool |
New in version 2.7.1..
IsLoaded
(self, domain)¶Calls wx.Translations.IsLoaded
.
Parameters: | domain (string) – |
---|---|
Return type: | bool |
IsOk
(self)¶Returns True
if the locale could be set successfully.
Return type: | bool |
---|
__nonzero__
(self)¶Return type: | int |
---|
CanonicalName
¶See GetCanonicalName
Language
¶See GetLanguage
SysName
¶See GetSysName