#include <wx/uilocale.h>
Represents a locale in a portable way.
There are two possible ways to construct wxLocaleIdent:
language ["-" script] ["-" region]
, corresponding to the subset of BCP 47 (https://www.rfc-editor.org/rfc/bcp/bcp47.txt) syntax.The first method is useful for interoperating with the other software using BCP 47 language tags, while the second one may may result in more readable code and allows to specify Unix-specific locale description parts such as charset and modifier that are not part of the BCP 47 strings.
Example of using wxLocaleIdent in the second way:
For the first way, it is enough to just write
Public Member Functions | |
wxLocaleIdent () | |
Default constructor creates an empty and invalid locale identifier. More... | |
wxLocaleIdent & | Language (const wxString &language) |
Set language. More... | |
wxLocaleIdent & | Region (const wxString ®ion) |
Set region. More... | |
wxLocaleIdent & | Script (const wxString &script) |
Set script. More... | |
wxLocaleIdent & | Charset (const wxString &charset) |
Set charset. More... | |
wxLocaleIdent & | Modifier (const wxString &modifier) |
Set modifier. More... | |
wxLocaleIdent & | Extension (const wxString &extension) |
Set extension. More... | |
wxLocaleIdent & | Sortorder (const wxString &sortorder) |
Set sortorder. More... | |
const wxString & | GetLanguage () const |
Return the language part of the locale identifier. More... | |
const wxString & | GetRegion () const |
Return the region part of the locale identifier. More... | |
const wxString & | GetScript () const |
Return the script part of the locale identifier. More... | |
const wxString & | GetCharset () const |
Return the charset part of the locale identifier. More... | |
const wxString & | GetModifier () const |
Return the modifier part of the locale identifier. More... | |
const wxString & | GetExtension () const |
Return the extension part of the locale identifier. More... | |
const wxString & | GetSortorder () const |
Return the sortorder part of the locale identifier. More... | |
wxString | GetName () const |
Construct platform dependent name. More... | |
wxString | GetTag (wxLocaleTagType tagType=wxLOCALE_TAGTYPE_DEFAULT) const |
Construct name in specified format. More... | |
bool | IsEmpty () const |
Check if the locale is empty. More... | |
Static Public Member Functions | |
static wxLocaleIdent | FromTag (const wxString &tag) |
Return the locale identifier corresponding to the given locale tag. More... | |
wxLocaleIdent::wxLocaleIdent | ( | ) |
Default constructor creates an empty and invalid locale identifier.
At least Language() must be called to make the identifier valid.
wxLocaleIdent& wxLocaleIdent::Charset | ( | const wxString & | charset | ) |
Set charset.
Note that this value is only used under Unix systems and simply ignored under the other ones.
Return reference to this
for method chaining.
charset | Charset is a string such as "UTF-8", "ISO855915" or "KOI8R". Supported charsets depend on the implementation and installation. |
wxLocaleIdent& wxLocaleIdent::Extension | ( | const wxString & | extension | ) |
Set extension.
Note that this value is only used under Windows systems and simply ignored under the other ones.
Return reference to this
for method chaining.
extension | Extension identifiers allow to support custom Windows locales. They are usually not portable, not even from one Windows system to the other. |
|
static |
Return the locale identifier corresponding to the given locale tag.
This method accepts locale tags in various formats:
See section 2.01 of https://www.rfc-editor.org/rfc/bcp/bcp47.txt for the full BCP-47 syntax. Here we fully support just the subset we're interested in:
Additionally platform-specific tags are supported:
Only language, script, and region are supported across all platforms. The script tag is mapped to the modifier tag for POSIX platforms. The script tag takes precedence, if a modifier is also specified.
The following tag syntax is accepted:
The string must contain at least the language part (2 or 3 ASCII letters) and may contain script and region separated by dashes, i.e. all of the following are valid:
Note that while BCP 47 extlangs, variants, extensions, private use and grandfathered tags are currently not directly supported, they may still work for creating wxUILocale on platforms with native support for BCP 47 strings.
If the input argument uses an unrecognized syntax (e.g. is empty), an empty wxLocaleIdent is returned. Of course, even if this function returns a non-empty object, the resulting locale may still be invalid or unsupported, use wxUILocale::IsSupported() to check for this.
Note that the format "MSVC CRT" (Microsoft Visual C++ C RunTime) is only supported as an input format, so that locale names as returned by the CRT function setlocale can be handled, mainly for compatibility with wxLocale.
const wxString& wxLocaleIdent::GetCharset | ( | ) | const |
Return the charset part of the locale identifier.
const wxString& wxLocaleIdent::GetExtension | ( | ) | const |
Return the extension part of the locale identifier.
const wxString& wxLocaleIdent::GetLanguage | ( | ) | const |
Return the language part of the locale identifier.
const wxString& wxLocaleIdent::GetModifier | ( | ) | const |
Return the modifier part of the locale identifier.
wxString wxLocaleIdent::GetName | ( | ) | const |
Construct platform dependent name.
Format:
const wxString& wxLocaleIdent::GetRegion | ( | ) | const |
Return the region part of the locale identifier.
const wxString& wxLocaleIdent::GetScript | ( | ) | const |
Return the script part of the locale identifier.
const wxString& wxLocaleIdent::GetSortorder | ( | ) | const |
Return the sortorder part of the locale identifier.
wxString wxLocaleIdent::GetTag | ( | wxLocaleTagType | tagType = wxLOCALE_TAGTYPE_DEFAULT | ) | const |
Construct name in specified format.
Format:
tagType | Value from wxLocaleTagType enum. |
bool wxLocaleIdent::IsEmpty | ( | ) | const |
Check if the locale is empty.
wxLocaleIdent& wxLocaleIdent::Language | ( | const wxString & | language | ) |
Set language.
Return reference to this
for method chaining.
See https://www.loc.gov/standards/iso639-2/php/English_list.php for the list of all language codes.
language | A two-letter ISO 639-1 language code or a three-letter ISO 639-2 code for the languages without ISO 639-1 codes. |
wxLocaleIdent& wxLocaleIdent::Modifier | ( | const wxString & | modifier | ) |
Set modifier.
Note that this value is only used under Unix systems and simply ignored under the other ones. Note that under Unix systems the modifier value may represent a script value. If the value corresponds to a valid script alias it is mapped to the associated script tag.
Return reference to this
for method chaining.
modifier | Modifier is a free-form text string. |
wxLocaleIdent& wxLocaleIdent::Region | ( | const wxString & | region | ) |
Set region.
Return reference to this
for method chaining.
region | It specifies an uppercase ISO 3166-1 country/region identifier. |
wxLocaleIdent& wxLocaleIdent::Script | ( | const wxString & | script | ) |
Set script.
Note that under Unix systems the script value is currently mapped to the modifier attribute using the script alias name, if the latter is known. Otherwise it is ignored.
Return reference to this
for method chaining.
script | It is an initial-uppercase ISO 15924 script code. |
wxLocaleIdent& wxLocaleIdent::Sortorder | ( | const wxString & | sortorder | ) |
Set sortorder.
Note that this value is only used under Windows systems and simply ignored under the other ones.
Return reference to this
for method chaining.
sortorder | Sortorder identifiers are defined in the Windows Development documentation: https://docs.microsoft.com/en-us/windows/win32/intl/sort-order-identifiers. |