Class: Wx::Locale
- Inherits:
-
Object
- Object
- Wx::Locale
- 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.
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
Class Method Summary collapse
-
.add_catalog_lookup_path_prefix(prefix) ⇒ void
Calls Wx::FileTranslationsLoader#add_catalog_lookup_path_prefix.
-
.add_language(info) ⇒ void
Adds custom, user-defined language to the database of known languages.
-
.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”).
-
.get_info(index, cat = Wx::LocaleCategory::LOCALE_CAT_DEFAULT) ⇒ String
Get the values of the given locale-dependent datum.
-
.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.
-
.get_language_info(lang) ⇒ Wx::LanguageInfo
Returns a pointer to LanguageInfo structure containing information about the given language or NULL if this language is unknown.
-
.get_language_name(lang) ⇒ String
Returns English name of the given language or empty string if this language is unknown.
-
.get_os_info(index, cat = Wx::LocaleCategory::LOCALE_CAT_DEFAULT) ⇒ String
Get the values of a locale datum in the OS locale.
-
.get_system_encoding ⇒ Wx::FontEncoding
Tries to detect the user’s default font encoding.
-
.get_system_encoding_name ⇒ String
Tries to detect the name of the user’s default font encoding.
-
.get_system_language ⇒ Integer
Tries to detect the user’s default locale setting.
-
.is_available(lang) ⇒ Boolean
Check whether the operating system and/or C run time environment supports this locale.
Instance Method Summary collapse
- #add_catalog(*args) ⇒ Object
-
#get_canonical_name ⇒ String
(also: #canonical_name)
Returns the canonical form of current locale name.
-
#get_header_value(header, domain = ('')) ⇒ String
(also: #header_value)
Calls Wx::Translations#get_header_value.
-
#get_language ⇒ Integer
(also: #language)
Returns the Language constant of current language.
-
#get_locale ⇒ Wx::String
(also: #locale)
Returns the locale name as passed to the constructor or #init.
-
#get_name ⇒ Wx::String
(also: #name)
Returns the current short name for the locale (as given to the constructor or the #init function).
- #get_string(*args) ⇒ Object (also: #string)
-
#get_sys_name ⇒ String
(also: #sys_name)
Returns current platform-specific locale name as passed to setlocale().
-
#init(language = Wx::Language::LANGUAGE_DEFAULT, flags = Wx::LocaleInitFlags::LOCALE_LOAD_DEFAULT) ⇒ Boolean
Initializes the Locale instance.
-
#initialize(*args) ⇒ Locale
constructor
A new instance of Locale.
-
#is_loaded(domain) ⇒ Boolean
(also: #loaded?)
Calls Wx::Translations#is_loaded.
-
#is_ok ⇒ Boolean
(also: #ok?)
Returns true if the locale could be set successfully.
Constructor Details
#initialize ⇒ Wx::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.
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.
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.
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.
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.
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.
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.
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.
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.
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_encoding ⇒ Wx::FontEncoding
Tries to detect the user’s default font encoding.
Returns font_encoding value or FontEncoding::FONTENCODING_SYSTEM if it couldn’t be determined.
3967 |
# File 'lib/wx/doc/gen/locale.rb', line 3967 def self.get_system_encoding; end |
.get_system_encoding_name ⇒ String
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.
3974 |
# File 'lib/wx/doc/gen/locale.rb', line 3974 def self.get_system_encoding_name; end |
.get_system_language ⇒ Integer
Tries to detect the user’s default locale setting.
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.
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.
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
3840 |
# File 'lib/wx/doc/gen/locale.rb', line 3840 def add_catalog(*args) end |
#get_canonical_name ⇒ String 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.
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.
3853 |
# File 'lib/wx/doc/gen/locale.rb', line 3853 def get_header_value(header, domain=('')) end |
#get_language ⇒ Integer 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.
3860 |
# File 'lib/wx/doc/gen/locale.rb', line 3860 def get_language; end |
#get_locale ⇒ Wx::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”.
3867 |
# File 'lib/wx/doc/gen/locale.rb', line 3867 def get_locale; end |
#get_name ⇒ Wx::String Also known as: name
Returns the current short name for the locale (as given to the constructor or the #init function).
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
3887 |
# File 'lib/wx/doc/gen/locale.rb', line 3887 def get_string(*args) end |
#get_sys_name ⇒ String Also known as: sys_name
Returns current platform-specific locale name as passed to setlocale().
Compare #get_canonical_name.
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.
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.
3913 |
# File 'lib/wx/doc/gen/locale.rb', line 3913 def is_loaded(domain) end |
#is_ok ⇒ Boolean Also known as: ok?
Returns true if the locale could be set successfully.
3918 |
# File 'lib/wx/doc/gen/locale.rb', line 3918 def is_ok; end |