Search documentation of wx

# View Source wxLocale (wx v2.4.3)

`wxLocale` 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 `wxTranslations` (not implemented in wx) object that manages message catalogs.

For a list of the supported languages, please see ?wxLanguage enum values. These constants may be used to specify the language in `init/3` and are returned by `getSystemLanguage/0`.

See:

- Overview i18n

- Examples

wxWidgets docs: wxLocale

# Summary

## Types

wxLocale()

## Functions

addCatalog(This, Domain)

Calls wxTranslations::AddCatalog(const wxString&).

addCatalog(This, Domain, MsgIdLanguage)

Calls `wxTranslations::AddCatalog(const wxString&, wxLanguage)` (not implemented in wx).

addCatalog(This, Domain, MsgIdLanguage, MsgIdCharset)

Calls `wxTranslations::AddCatalog(const wxString&, wxLanguage, const wxString&)` (not implemented in wx).

addCatalogLookupPathPrefix(Prefix)

Calls `wxFileTranslationsLoader::AddCatalogLookupPathPrefix()` (not implemented in wx).

destroy(This)

Destroys the object

getCanonicalName(This)

Returns the canonical form of current locale name.

getHeaderValue(This, Header)

Equivalent to `getHeaderValue(This, Header, [])`.

getHeaderValue/3

Calls `wxTranslations::GetHeaderValue()` (not implemented in wx).

getLanguage(This)

Returns the ?wxLanguage constant of current language.

getLanguageName(Lang)

Returns English name of the given language or empty string if this language is unknown.

getLocale(This)

Returns the locale name as passed to the constructor or `init/3`.

getName(This)

Returns the current short name for the locale (as given to the constructor or the `init/3` function).

getString(This, OrigString)

Equivalent to `getString(This, OrigString, [])`.

getString/3

Calls wxGetTranslation(const wxString&, const wxString&).

getString(This, OrigString, OrigString2, N)

Equivalent to `getString(This, OrigString, OrigString2, N, [])`.

getString/5

Calls wxGetTranslation(const wxString&, const wxString&, unsigned, const wxString&).

getSysName(This)

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(This)

Equivalent to `init(This, [])`.

init/2

Initializes the `wxLocale` instance.

init/3

Deprecated

isLoaded(This, Domain)

Calls `wxTranslations::IsLoaded()` (not implemented in wx).

isOk(This)

Returns true if the locale could be set successfully.

new()

This is the default constructor and it does nothing to initialize the object: `init/3` must be used to do that.

new/1

Equivalent to: `new/2`

new/2

See `init/3` for parameters description.

# Types

Link to this type

# wxLocale()

View Source

    -type wxLocale() :: wx:wx_object().

# Functions

Link to this function

# addCatalog(This, Domain)

View Source

    -spec addCatalog(This, Domain) -> boolean() when This :: wxLocale(), Domain :: unicode:chardata().

Calls wxTranslations::AddCatalog(const wxString&).

Link to this function

# addCatalog(This, Domain, MsgIdLanguage)

View Source

    -spec addCatalog(This, Domain, MsgIdLanguage) -> boolean()
                        when This :: wxLocale(), Domain :: unicode:chardata(), MsgIdLanguage :: wx:wx_enum().

Calls `wxTranslations::AddCatalog(const wxString&, wxLanguage)` (not implemented in wx).

Link to this function

# addCatalog(This, Domain, MsgIdLanguage, MsgIdCharset)

View Source

    -spec addCatalog(This, Domain, MsgIdLanguage, MsgIdCharset) -> boolean()
                        when
                            This :: wxLocale(),
                            Domain :: unicode:chardata(),
                            MsgIdLanguage :: wx:wx_enum(),
                            MsgIdCharset :: unicode:chardata().

Calls `wxTranslations::AddCatalog(const wxString&, wxLanguage, const wxString&)` (not implemented in wx).

Link to this function

# addCatalogLookupPathPrefix(Prefix)

View Source

    -spec addCatalogLookupPathPrefix(Prefix) -> ok when Prefix :: unicode:chardata().

Calls `wxFileTranslationsLoader::AddCatalogLookupPathPrefix()` (not implemented in wx).

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxLocale()) -> ok.

Destroys the object

Link to this function

# getCanonicalName(This)

View Source

    -spec getCanonicalName(This) -> unicode:charlist() when This :: wxLocale().

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/1`.

Link to this function

# getHeaderValue(This, Header)

View Source

    -spec getHeaderValue(This, Header) -> unicode:charlist()
                            when This :: wxLocale(), Header :: unicode:chardata().

Equivalent to `getHeaderValue(This, Header, [])`.

Link to this function

# getHeaderValue/3

View Source

    -spec getHeaderValue(This, Header, [Option]) -> unicode:charlist()
                            when
                                This :: wxLocale(),
                                Header :: unicode:chardata(),
                                Option :: {szDomain, unicode:chardata()}.

Calls `wxTranslations::GetHeaderValue()` (not implemented in wx).

Link to this function

# getLanguage(This)

View Source

    -spec getLanguage(This) -> integer() when This :: wxLocale().

Returns the ?wxLanguage constant of current language.

Note that you can call this function only if you used the form of `init/3` that takes ?wxLanguage argument.

Link to this function

# getLanguageName(Lang)

View Source

    -spec getLanguageName(Lang) -> unicode:charlist() when Lang :: integer().

Returns English name of the given language or empty string if this language is unknown.

See `GetLanguageInfo()` (not implemented in wx) for a remark about special meaning of `wxLANGUAGE_DEFAULT`.

Link to this function

# getLocale(This)

View Source

    -spec getLocale(This) -> unicode:charlist() when This :: wxLocale().

Returns the locale name as passed to the constructor or `init/3`.

This is a full, human-readable name, e.g. "English" or "French".

Link to this function

# getName(This)

View Source

    -spec getName(This) -> unicode:charlist() when This :: wxLocale().

Returns the current short name for the locale (as given to the constructor or the `init/3` function).

Link to this function

# getString(This, OrigString)

View Source

    -spec getString(This, OrigString) -> unicode:charlist()
                       when This :: wxLocale(), OrigString :: unicode:chardata().

Equivalent to `getString(This, OrigString, [])`.

Link to this function

# getString/3

View Source

    -spec getString(This, OrigString, [Option]) -> unicode:charlist()
                       when
                           This :: wxLocale(),
                           OrigString :: unicode:chardata(),
                           Option :: {szDomain, unicode:chardata()}.

Calls wxGetTranslation(const wxString&, const wxString&).

Link to this function

# getString(This, OrigString, OrigString2, N)

View Source

    -spec getString(This, OrigString, OrigString2, N) -> unicode:charlist()
                       when
                           This :: wxLocale(),
                           OrigString :: unicode:chardata(),
                           OrigString2 :: unicode:chardata(),
                           N :: integer().

Equivalent to `getString(This, OrigString, OrigString2, N, [])`.

Link to this function

# getString/5

View Source

    -spec getString(This, OrigString, OrigString2, N, [Option]) -> unicode:charlist()
                       when
                           This :: wxLocale(),
                           OrigString :: unicode:chardata(),
                           OrigString2 :: unicode:chardata(),
                           N :: integer(),
                           Option :: {szDomain, unicode:chardata()}.

Calls wxGetTranslation(const wxString&, const wxString&, unsigned, const wxString&).

Link to this function

# getSysName(This)

View Source

    -spec getSysName(This) -> unicode:charlist() when This :: wxLocale().

Returns current platform-specific locale name as passed to setlocale().

Compare `getCanonicalName/1`.

Link to this function

# getSystemEncoding()

View Source

    -spec getSystemEncoding() -> wx:wx_enum().

Tries to detect the user's default font encoding.

Returns ?wxFontEncoding() value or `wxFONTENCODING_SYSTEM` if it couldn't be determined.

Link to this function

# getSystemEncodingName()

View Source

    -spec getSystemEncodingName() -> unicode:charlist().

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/0` instead.

Returns a user-readable string value or an empty string if it couldn't be determined.

Link to this function

# getSystemLanguage()

View Source

    -spec getSystemLanguage() -> integer().

Tries to detect the user's default locale setting.

Returns the ?wxLanguage value or `wxLANGUAGE_UNKNOWN` if the language-guessing algorithm failed.

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 wxTranslation to obtain `language` information.

Link to this function

# init(This)

View Source

    -spec init(This) -> boolean() when This :: wxLocale().

Equivalent to `init(This, [])`.

Link to this function

# init/2

View Source

    -spec init(This, [Option]) -> boolean()
                  when This :: wxLocale(), Option :: {language, integer()} | {flags, integer()}.

Initializes the `wxLocale` 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 `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.

Return: true on success or false if the given locale couldn't be set.

Link to this function

# init/3

View Source

    -spec init(This, Name, [Option]) -> boolean()
                  when
                      This :: wxLocale(),
                      Name :: unicode:chardata(),
                      Option ::
                          {shortName, unicode:chardata()} |
                          {locale, unicode:chardata()} |
                          {bLoadDefault, boolean()}.

Deprecated:

This form is deprecated, use the other one unless you know what you are doing.

Link to this function

# isLoaded(This, Domain)

View Source

    -spec isLoaded(This, Domain) -> boolean() when This :: wxLocale(), Domain :: unicode:chardata().

Calls `wxTranslations::IsLoaded()` (not implemented in wx).

Link to this function

# isOk(This)

View Source

    -spec isOk(This) -> boolean() when This :: wxLocale().

Returns true if the locale could be set successfully.

Link to this function

# new()

View Source

    -spec new() -> wxLocale().

This is the default constructor and it does nothing to initialize the object: `init/3` must be used to do that.

Link to this function

# new/1

View Source

    -spec new(Language) -> wxLocale() when Language :: integer();
             (Name) -> wxLocale() when Name :: unicode:chardata().

Equivalent to: `new/2`

Link to this function

# new/2

View Source

    -spec new(Language, [Option]) -> wxLocale() when Language :: integer(), Option :: {flags, integer()};
             (Name, [Option]) -> wxLocale()
                 when
                     Name :: unicode:chardata(),
                     Option ::
                         {shortName, unicode:chardata()} |
                         {locale, unicode:chardata()} |
                         {bLoadDefault, boolean()}.

See `init/3` 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 `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.