Class: Wx::Locale

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/locale.rb

Overview

Locale class encapsulates all language-dependent settings and is a generalization of the C locale concept.

Note:

This class is known to have several problems under macOS: first of all, it is impossible to change the application UI locale after launching it under this platform and so using this class doesn't affect the native controls and dialogs there. Additionally, versions of macOS between 11.0 and 12.2 inclusive are affected by a bug when changing C locale can break display of the application menus. Because of this, it is recommended to use UILocale instead of this class for the applications targeting macOS.

In wxWidgets this class manages current locale. It also initializes and activates Translations object that manages message catalogs. For a list of the supported languages, please see Language enum values. These constants may be used to specify the language in #init and are returned by Locale.get_system_language.

Category: Application and System configuration

See Also:

  • Internationalization
  • Sample
  • XLocale
  • Translations

Requires:

  • USE_INTL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWx::Locale #initialize(language, flags = Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT) ⇒ Wx::Locale #initialize(name, shortName = (''), locale = (''), bLoadDefault = true) ⇒ Wx::Locale

Returns a new instance of Locale.

Overloads:

  • #initializeWx::Locale

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

  • #initialize(language, flags = Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT) ⇒ Wx::Locale

    See #init for parameters description.

    Parameters:

    • language (Integer)
    • flags (Integer) (defaults to: Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT)
  • #initialize(name, shortName = (''), locale = (''), bLoadDefault = true) ⇒ Wx::Locale

    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 get_translation will try to translate the messages using the message catalogs for this locale.

    Parameters:

    • name (String)
    • shortName (String) (defaults to: (''))
    • locale (String) (defaults to: (''))
    • bLoadDefault (Boolean) (defaults to: true)


3823
# File 'lib/wx/doc/gen/locale.rb', line 3823

def initialize(*args) end

Class Method Details

.add_catalog_lookup_path_prefix(prefix) ⇒ void

This method returns an undefined value.

Calls Wx::FileTranslationsLoader#add_catalog_lookup_path_prefix.

Parameters:

  • prefix (String)


3924
# File 'lib/wx/doc/gen/locale.rb', line 3924

def self.add_catalog_lookup_path_prefix(prefix) end

.add_language(info) ⇒ void

This method returns an undefined value.

Adds custom, user-defined language to the database of known languages.

This database is used in conjunction with the first form of #init.

Parameters:



3931
# File 'lib/wx/doc/gen/locale.rb', line 3931

def self.add_language(info) end

.find_language_info(locale) ⇒ Wx::LanguageInfo

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 NULL if this language is unknown. Note that even if the returned pointer is valid, the caller should not delete it.

Parameters:

  • locale (String)

Returns:

See Also:



3939
# File 'lib/wx/doc/gen/locale.rb', line 3939

def self.find_language_info(locale) end

.get_info(index, cat = Wx::LocaleCategory::LOCALE_CAT_DEFAULT) ⇒ String

Get the values of the given locale-dependent datum.

This function returns the value of the locale-specific option specified by the given index.

The option value or empty string if the function failed.

Parameters:

Returns:

  • (String)


3997
# File 'lib/wx/doc/gen/locale.rb', line 3997

def self.get_info(index, cat=Wx::LocaleCategory::LOCALE_CAT_DEFAULT) end

.get_language_canonical_name(lang) ⇒ String

Returns canonical name (see #get_canonical_name) of the given language or empty string if this language is unknown.

See get_language_info for a remark about special meaning of Wx::Language::LANGUAGE_DEFAULT.

Parameters:

  • lang (Integer)

Returns:

  • (String)


3961
# File 'lib/wx/doc/gen/locale.rb', line 3961

def self.get_language_canonical_name(lang) end

.get_language_info(lang) ⇒ Wx::LanguageInfo

Returns a pointer to Wx::LanguageInfo 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 not delete it. See add_language for the Wx::LanguageInfo description. As with #init, Wx::Language::LANGUAGE_DEFAULT has the special meaning if passed as an argument to this function and in this case the result of get_system_language is used.

Parameters:

  • lang (Integer)

Returns:



3947
# File 'lib/wx/doc/gen/locale.rb', line 3947

def self.get_language_info(lang) end

.get_language_name(lang) ⇒ String

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

See get_language_info for a remark about special meaning of Wx::Language::LANGUAGE_DEFAULT.

Parameters:

  • lang (Integer)

Returns:

  • (String)


3954
# File 'lib/wx/doc/gen/locale.rb', line 3954

def self.get_language_name(lang) end

.get_os_info(index, cat = Wx::LocaleCategory::LOCALE_CAT_DEFAULT) ⇒ String

Get the values of a locale datum in the OS locale.

This function shouldn’t be used in the new code, use Wx::UILocale#get_info instead. This function is similar to get_info and, in fact, identical to it under non-MSW systems. Under MSW it differs from it when no locale had been explicitly set: get_info returns the values corresponding to the “C” locale used by the standard library functions, while this method returns the values used by the OS which, in Windows case, correspond to the user settings in the control panel.

Parameters:

Returns:

  • (String)


4006
# File 'lib/wx/doc/gen/locale.rb', line 4006

def self.get_os_info(index, cat=Wx::LocaleCategory::LOCALE_CAT_DEFAULT) end

.get_system_encodingWx::FontEncoding

Tries to detect the user’s default font encoding.

Returns font_encoding value or FontEncoding::FONTENCODING_SYSTEM if it couldn’t be determined.

Returns:



3967
# File 'lib/wx/doc/gen/locale.rb', line 3967

def self.get_system_encoding; end

.get_system_encoding_nameString

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 get_system_encoding instead. Returns a user-readable string value or an empty string if it couldn’t be determined.

Returns:

  • (String)


3974
# File 'lib/wx/doc/gen/locale.rb', line 3974

def self.get_system_encoding_name; end

.get_system_languageInteger

Tries to detect the user’s default locale setting.

Note:

This function is somewhat misleading, as it uses the default system locale to determine its return value, and not just the system language. It is preserved for backwards compatibility, but to actually get the language, and not locale, used by the system by default, call Wx::UILocale#get_system_language instead.

Returns the Wx::Language value or Wx::Language::LANGUAGE_UNKNOWN if the locale is not recognized, as can notably happen when combining any language with a region where this language is not typically spoken.

Returns:

  • (Integer)

See Also:

  • Translations#get_best_translation.


3987
# File 'lib/wx/doc/gen/locale.rb', line 3987

def self.get_system_language; end

.is_available(lang) ⇒ Boolean

Check whether the operating system and/or C run time environment supports this locale.

For example in Windows, 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 find_language_info to obtain its Wx::LanguageInfo structure. See add_language for the Wx::LanguageInfo description.

Parameters:

  • lang (Integer)

Returns:

  • (Boolean)


4014
# File 'lib/wx/doc/gen/locale.rb', line 4014

def self.is_available(lang) end

Instance Method Details

#add_catalog(domain) ⇒ Boolean #add_catalog(domain, msgIdLanguage) ⇒ Boolean #add_catalog(domain, msgIdLanguage, msgIdCharset) ⇒ Boolean

Overloads:

  • #add_catalog(domain) ⇒ Boolean

    Calls Wx::Translations#add_catalog(wxString).

    Parameters:

    • domain (String)

    Returns:

    • (Boolean)
  • #add_catalog(domain, msgIdLanguage) ⇒ Boolean

    Calls wxTranslations::AddCatalog(const wxString&, wxLanguage).

    Parameters:

    Returns:

    • (Boolean)
  • #add_catalog(domain, msgIdLanguage, msgIdCharset) ⇒ Boolean

    Calls wxTranslations::AddCatalog(const wxString&, wxLanguage, const wxString&).

    Parameters:

    • domain (String)
    • msgIdLanguage (Wx::Language)
    • msgIdCharset (String)

    Returns:

    • (Boolean)


3840
# File 'lib/wx/doc/gen/locale.rb', line 3840

def add_catalog(*args) end

#get_canonical_nameString Also known as: canonical_name

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 #get_sys_name.

Returns:

  • (String)


3846
# File 'lib/wx/doc/gen/locale.rb', line 3846

def get_canonical_name; end

#get_header_value(header, domain = ('')) ⇒ String Also known as: header_value

Calls Wx::Translations#get_header_value.

Parameters:

  • header (String)
  • domain (String) (defaults to: (''))

Returns:

  • (String)


3853
# File 'lib/wx/doc/gen/locale.rb', line 3853

def get_header_value(header, domain=('')) end

#get_languageInteger Also known as: language

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.

Returns:

  • (Integer)


3860
# File 'lib/wx/doc/gen/locale.rb', line 3860

def get_language; end

#get_localeWx::String Also known as: locale

Returns the locale name as passed to the constructor or #init.

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

Returns:

  • (Wx::String)


3867
# File 'lib/wx/doc/gen/locale.rb', line 3867

def get_locale; end

#get_nameWx::String Also known as: name

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

Returns:

  • (Wx::String)


3872
# File 'lib/wx/doc/gen/locale.rb', line 3872

def get_name; end

#get_string(origString, domain = ('')) ⇒ Wx::String #get_string(origString, origString2, n, domain = ('')) ⇒ Wx::String Also known as: string

Overloads:

  • #get_string(origString, domain = ('')) ⇒ Wx::String

    Calls get_translation(wxString,wxString).

    Parameters:

    • origString (String)
    • domain (String) (defaults to: (''))

    Returns:

    • (Wx::String)
  • #get_string(origString, origString2, n, domain = ('')) ⇒ Wx::String

    Calls get_translation(wxString,wxString,unsigned,wxString).

    Parameters:

    • origString (String)
    • origString2 (String)
    • n (unsigned)
    • domain (String) (defaults to: (''))

    Returns:

    • (Wx::String)


3887
# File 'lib/wx/doc/gen/locale.rb', line 3887

def get_string(*args) end

#get_sys_nameString Also known as: sys_name

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

Compare #get_canonical_name.

Returns:

  • (String)


3894
# File 'lib/wx/doc/gen/locale.rb', line 3894

def get_sys_name; end

#init(language = Wx::Language::LANGUAGE_DEFAULT, flags = Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT) ⇒ Boolean

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 get_translation will try to translate the messages using the message catalogs for this locale.

true on success or false if the given locale couldn’t be set.

Parameters:

Returns:

  • (Boolean)


3908
# File 'lib/wx/doc/gen/locale.rb', line 3908

def init(language=Wx::Language::LANGUAGE_DEFAULT, flags=Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT) end

#is_loaded(domain) ⇒ Boolean Also known as: loaded?

Calls Wx::Translations#is_loaded.

Parameters:

  • domain (String)

Returns:

  • (Boolean)


3913
# File 'lib/wx/doc/gen/locale.rb', line 3913

def is_loaded(domain) end

#is_okBoolean Also known as: ok?

Returns true if the locale could be set successfully.

Returns:

  • (Boolean)


3918
# File 'lib/wx/doc/gen/locale.rb', line 3918

def is_ok; end