xtd 0.2.0
Loading...
Searching...
No Matches
xtd::globalization::culture_info Class Reference
Inheritance diagram for xtd::globalization::culture_info:
xtd::object xtd::iequatable< xtd::globalization::culture_info > xtd::interface xtd::extensions::equality_operators< xtd::globalization::culture_info, iequatable< xtd::globalization::culture_info > >

Definition

Provides information about a specific culture (called a locale for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, the sort order of strings, and formatting for dates and numbers.

class culture_info : public xtd::object, public xtd::iequatable<xtd::globalization::culture_info>
culture_info()
Initializes a new instance of the xtd::globalization::culture_info class.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Inheritance
xtd::objectxtd::globalization::culture_info
Header
#include <xtd/globalization/culture_info>
Namespace
xtd::globalization
Library
xtd.core
Examples
The following example shows how to create a xtd::globalization::culture_info object for Spanish (Spain) with the international sort and another xtd::globalization::culture_info object with the traditional sort.
Examples
date_time_now.cpp, date_time_now2.cpp, format_class_with_specified_formating.cpp, format_exception.cpp, format_floating_point.cpp, iformatable.cpp, parse_floating_point.cpp, parse_numeric.cpp, translator.cpp, and translator_with_language.cpp.

Public Constructors

 culture_info ()
 Initializes a new instance of the xtd::globalization::culture_info class.
 
 culture_info (culture_info &&culture)=default
 Initializes a new instance of the xtd::globalization::culture_info class with specified culture.
 
 culture_info (const culture_info &culture)=default
 Initializes a new instance of the xtd::globalization::culture_info class with specified culture.
 
 culture_info (const std::locale &locale)
 Initializes a new instance of the xtd::globalization::culture_info class with specified locale.
 
 culture_info (xtd::size culture)
 Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by the culture identifier.
 
 culture_info (xtd::size culture, bool use_user_override)
 Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by the culture identifier and on a value that specifies whether to use the user-selected culture settings from Windows.
 
 culture_info (const xtd::string &name)
 Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by name.
 
 culture_info (const xtd::string &name, bool use_user_override)
 Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by name and on a value that specifies whether to use the user-selected culture settings from Windows.
 

Public Properties

xtd::globalization::culture_types culture_types () const noexcept
 Gets the culture types that pertain to the current xtd::globalization::culture_info object.
 
const xtd::globalization::date_time_format_infodate_time_format () const
 Gets or sets a xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.
 
xtd::globalization::date_time_format_infodate_time_format ()
 Gets or sets a xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.
 
const xtd::stringdisplay_name () const noexcept
 Gets the full localized culture name.
 
const xtd::stringenglish_name () const noexcept
 Gets the culture name in the format languagefull [country/regionfull] in English.
 
bool is_locale_available () const noexcept
 Gets a value indicateing if the std::locale corresponding to this instance is available.
 
bool is_read_only () const noexcept
 Gets a value indicating whether the current xtd::globalization::culture_info is read-only.
 
bool is_neutral_culture () const noexcept
 Gets a value indicating whether the current xtd::globalization::culture_info represents a neutral culture.
 
xtd::size keyboard_layout_id () const noexcept
 Gets the active input locale identifier.
 
xtd::size lcid () const noexcept
 Gets the culture identifier for the current xtd::globalization::culture_info.
 
const std::locale & locale () const noexcept
 Gets the std::locale associate for the current xtd::globalization::culture_info.
 
const xtd::stringname () const noexcept
 Gets the culture name in the format languagecode2-country/regioncode2.
 
const xtd::stringnative_name () const noexcept
 Gets the culture name, consisting of the language, the country/region, and the optional script, that the culture is set to display.
 
const xtd::globalization::number_format_infonumber_format () const
 
xtd::globalization::number_format_infonumber_format ()
 
virtual xtd::globalization::culture_info parent () const noexcept
 Gets the xtd::globalization::culture_info that represents the parent culture of the current xtd::globalization::culture_info.
 
const xtd::stringthree_letter_iso_language_name () const noexcept
 Gets the ISO 639-2 three-letter code for the language of the current xtd::globalization::culture_info.
 
const xtd::stringthree_letter_windows_language_name () const noexcept
 Gets the three-letter code for the language as defined in the Windows API.
 
const xtd::stringtwo_letter_iso_language_name () const noexcept
 Gets the ISO 639-1 two-letter or ISO 639-3 three-letter code for the language of the current xtd::globalization::culture_info.
 
bool use_user_override () const noexcept
 Gets a value indicating whether the current xtd::globalization::culture_info object uses the user-selected culture settings.
 

Public Methods

culture_info clone () const noexcept
 Creates a copy of the current xtd::globalization::culture_info.
 
bool equals (const object &obj) const noexcept override
 Determines whether the specified object is equal to the current object.
 
bool equals (const culture_info &obj) const noexcept override
 Indicates whether the current object is equal to another object of the same type.
 
xtd::size get_hash_code () const noexcept override
 Returns the hash code for this basic_string.
 
xtd::string to_string () const noexcept override
 Returns a xtd::string that represents the current object.
 

Public Operators

 operator const std::locale & () const noexcept
 The std::locale operator that convert this xtd::globalization::culture_info in std::locale associate.
 

Public Static Properties

static culture_info current_culture () noexcept
 Gets the xtd::globalization::culture_info object that represents the culture used by the current application.
 
static void current_culture (const culture_info &value)
 Sets the xtd::globalization::culture_info object that represents the culture used by the current application.
 
static culture_info invariant_culture () noexcept
 Gets the xtd::globalization::culture_info object that is culture-independent (invariant).
 

Public Static Methods

static culture_info get_culture_info (const xtd::string &name)
 Retrieves a cached, read-only instance of a culture using the specified culture name.
 
static culture_info get_culture_info (const xtd::string &name, bool predefined_only)
 Retrieves a cached, read-only instance of a culture.
 
static culture_info get_culture_info (const xtd::string &name, const xtd::string &alt_name)
 Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the TextInfo and CompareInfo objects specified by another culture.
 
static culture_info get_culture_info (xtd::size culture)
 Retrieves a cached, read-only instance of a culture by using the specified culture identifier.
 
static xtd::array< culture_infoget_cultures (xtd::globalization::culture_types types)
 Gets the list of supported cultures filtered by the specified xtd::globalization::culture_types parameter.
 
static xtd::array< std::locale > get_system_locales () noexcept
 Gets the lists of system locales.
 
static void initialize_all_cultures () noexcept
 Initializes all cultures available in xtd and prevents lazy-loading.
 

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
template<class object_a_t, class object_b_t>
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t, class object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ culture_info() [1/8]

xtd::globalization::culture_info::culture_info ( )

Initializes a new instance of the xtd::globalization::culture_info class.

◆ culture_info() [2/8]

xtd::globalization::culture_info::culture_info ( culture_info && culture)
default

Initializes a new instance of the xtd::globalization::culture_info class with specified culture.

Parameters
cultureThe xtd::globalization::culture_info to inititalise this instance.

◆ culture_info() [3/8]

xtd::globalization::culture_info::culture_info ( const culture_info & culture)
default

Initializes a new instance of the xtd::globalization::culture_info class with specified culture.

Parameters
cultureThe xtd::globalization::culture_info to inititalise this instance.

◆ culture_info() [4/8]

xtd::globalization::culture_info::culture_info ( const std::locale & locale)

Initializes a new instance of the xtd::globalization::culture_info class with specified locale.

Parameters
localeThe std::locale to inititalise this instance.

◆ culture_info() [5/8]

xtd::globalization::culture_info::culture_info ( xtd::size culture)
explicit

Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by the culture identifier.

Parameters
cultureA predefined xtd::globalization::culture_info identifier, xtd::globalization::culture_info::lcid property of an existing xtd::globalization::culture_info object, or Windows-only culture identifier.
Exceptions
xtd::globalization::culture_not_found_exceptionculture is not a valid culture identifier. See the Notes to Callers section for more information.
Remarks
Predefined culture identifiers for cultures available on Windows system are listed in the Language tag column in the list of language/region names supported by Windows. Culture names follow the standard defined by BCP 47.

In most cases, the culture parameter is mapped to the corresponding National Language Support (NLS) locale identifier. The value of the culture parameter becomes the value of the xtd::globalization::culture_info::lcid property of the new xtd::globalization::culture_info.

We recommend that you call the locale name constructor xtd::globalization::culture_info::culture_info (const xtd::string& name), because locale names are preferable to LCIDs. For custom locales, a locale name is required.

The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a xtd::globalization::culture_info that uses those overrides, including user settings for the properties of the xtd::globalization::date_time_format_info instance returned by the xtd::globalization::culture_info::date_time_format property, and the properties of the xtd::globalization::number_format_info instance returned by the xtd::globalization::culture_info::number_format property. If the user settings are incompatible with the culture associated with the xtd::globalization::culture_info (for example, if the selected calendar is not one of the xtd::globalization::culture_info::optional_calendars) the results of the methods and the values of the properties are undefined.

For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.
  • With culture_info {0x0401} (culture name ar-SA), xtd::globalization::culture_info::calendar is set to xtd::globalization::gregorian_calendar (which is the user setting).
  • With culture_info {0x041E} (culture name th-TH), xtd::globalization::culture_info::calendar is set to xtd::globalization::thai_buddhist_calendar (which is the default calendar for th-TH).
Note
For backwards compatibility, a culture constructed using a culture parameter of 0x0004 or 0x7c04 will have a xtd::globalization::culture_info::name property of zh-CHS or zh-CHT, respectively. You should instead prefer to construct the culture using the current standard culture names of zh-Hans or zh-Hant, unless you have a reason for using the older names.

LCIDs are being deprecated, and implementers are strongly encouraged to use newer versions of APIs that support BCP 47 locale names instead. Each LCID can be represented by a BCP 47 locale name, but the reverse is not true. The LCID range is restricted and unable to uniquely identify all the possible combinations of language and region.

◆ culture_info() [6/8]

xtd::globalization::culture_info::culture_info ( xtd::size culture,
bool use_user_override )

Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by the culture identifier and on a value that specifies whether to use the user-selected culture settings from Windows.

Parameters
cultureA predefined xtd::globalization::culture_info identifier, xtd::globalization::culture_info::lcid property of an existing xtd::globalization::culture_info object, or Windows-only culture identifier.
use_user_overridetrue to use the user-selected culture settings (Windows only); false to use the default culture settings.
Exceptions
xtd::globalization::culture_not_found_exceptionculture is not a valid culture identifier. See the Notes to Callers section for more information.
Remarks
Predefined culture identifiers for cultures available on Windows system are listed in the Language tag column in the list of language/region names supported by Windows. Culture names follow the standard defined by BCP 47.

In most cases, the culture parameter is mapped to the corresponding National Language Support (NLS) locale identifier. The value of the culture parameter becomes the value of the xtd::globalization::culture_info::lcid property of the new xtd::globalization::culture_info.

We recommend that you call the locale name constructor xtd::globalization::culture_info::culture_info (const xtd::string& name), because locale names are preferable to LCIDs. For custom locales, a locale name is required.

The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a xtd::globalization::culture_info that uses those overrides, including user settings for the properties of the xtd::globalization::date_time_format_info instance returned by the xtd::globalization::culture_info::date_time_format property, and the properties of the xtd::globalization::number_format_info instance returned by the xtd::globalization::culture_info::number_format property. If the user settings are incompatible with the culture associated with the xtd::globalization::culture_info (for example, if the selected calendar is not one of the xtd::globalization::culture_info::optional_calendars) the results of the methods and the values of the properties are undefined.

For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.
  • With culture_info {0x0401} (culture name ar-SA), xtd::globalization::culture_info::calendar is set to xtd::globalization::gregorian_calendar (which is the user setting).
  • With culture_info {0x041E} (culture name th-TH), xtd::globalization::culture_info::calendar is set to xtd::globalization::thai_buddhist_calendar (which is the default calendar for th-TH).
Note
For backwards compatibility, a culture constructed using a culture parameter of 0x0004 or 0x7c04 will have a xtd::globalization::culture_info::name property of zh-CHS or zh-CHT, respectively. You should instead prefer to construct the culture using the current standard culture names of zh-Hans or zh-Hant, unless you have a reason for using the older names.

LCIDs are being deprecated, and implementers are strongly encouraged to use newer versions of APIs that support BCP 47 locale names instead. Each LCID can be represented by a BCP 47 locale name, but the reverse is not true. The LCID range is restricted and unable to uniquely identify all the possible combinations of language and region.

◆ culture_info() [7/8]

xtd::globalization::culture_info::culture_info ( const xtd::string & name)
explicit

Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by name.

Parameters
nameA predefined xtd::globalization::culture_info name, xtd::globalization::culture_info::name of an existing xtd::globalization::culture_info, or Windows-only culture name. name is not case-sensitive.
examples
The following example retrieves the current culture. If it is anything other than the French (France) culture, it calls the xtd::globalization::culture_info::culture_info (const string&) constructor to instantiate a xtd::globalization::culture_info object that represents the French (France) culture and makes it the current culture. Otherwise, it instantiates a xtd::globalization::culture_info object that represents the French (Luxembourg) culture and makes it the current culture.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
console::write_line("The current culture is {}", current.name());
auto new_culture = culture_info {};
if (current.name().equals("fr-FR"))
new_culture = culture_info {"fr-LU"};
else
new_culture = culture_info {"fr-FR"};
console::write_line("The current culture is now {}", culture_info::current_culture().name());
}
// This code produces the following output :
//
// The current culture is en-US
// The current culture is now fr-FR
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition culture_info.hpp:43
static culture_info current_culture() noexcept
Gets the xtd::globalization::culture_info object that represents the culture used by the current appl...
Contains classes that define culture-related information, including language, country/region,...
Definition culture_info.hpp:20
Remarks
For a list of predefined culture names on Windows systems, see the Language tag column in the list of language/region names supported by Windows. Culture names follow the standard defined by BCP 47.

If name is xtd::string::empty_string, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the xtd::globalization::culture_info::invariant_culture property.

The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a xtd::globalization::culture_info that uses those overrides, including user settings for the properties of the xtd::globalization::date_time_format_info instance returned by the xtd::globalization::culture_info::date_time_format property, and the properties of the xtd::globalization::number_format_info instance returned by the xtd::globalization::culture_info::number_format property. If the user settings are incompatible with the culture associated with the xtd::globalization::culture_info (for example, if the selected calendar is not one of the xtd::globalization::culture_info::optional_calendars) the results of the methods and the values of the properties are undefined.

For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.
  • With culture_info {0x0401} (culture name ar-SA), xtd::globalization::culture_info::calendar is set to xtd::globalization::gregorian_calendar (which is the user setting).
  • With culture_info {0x041E} (culture name th-TH), xtd::globalization::culture_info::calendar is set to xtd::globalization::thai_buddhist_calendar (which is the default calendar for th-TH).

◆ culture_info() [8/8]

xtd::globalization::culture_info::culture_info ( const xtd::string & name,
bool use_user_override )

Initializes a new instance of the xtd::globalization::culture_info class based on the culture specified by name and on a value that specifies whether to use the user-selected culture settings from Windows.

Parameters
nameA predefined xtd::globalization::culture_info name, xtd::globalization::culture_info::name of an existing xtd::globalization::culture_info, or Windows-only culture name. name is not case-sensitive.
use_user_overridetrue to use the user-selected culture settings (Windows only); false to use the default culture settings.
examples
The following example retrieves the current culture. If it is anything other than the French (France) culture, it calls the xtd::globalization::culture_info::culture_info (const string&) constructor to instantiate a xtd::globalization::culture_info object that represents the French (France) culture and makes it the current culture. Otherwise, it instantiates a xtd::globalization::culture_info object that represents the French (Luxembourg) culture and makes it the current culture.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
console::write_line("The current culture is {}", current.name());
auto new_culture = culture_info {};
if (current.name().equals("fr-FR"))
new_culture = culture_info {"fr-LU"};
else
new_culture = culture_info {"fr-FR"};
console::write_line("The current culture is now {}", culture_info::current_culture().name());
}
// This code produces the following output :
//
// The current culture is en-US
// The current culture is now fr-FR
Remarks
For a list of predefined culture names on Windows systems, see the Language tag column in the list of language/region names supported by Windows. Culture names follow the standard defined by BCP 47.

If name is xtd::string::empty_string, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the xtd::globalization::culture_info::invariant_culture property.

The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a xtd::globalization::culture_info that uses those overrides, including user settings for the properties of the xtd::globalization::date_time_format_info instance returned by the xtd::globalization::culture_info::date_time_format property, and the properties of the xtd::globalization::number_format_info instance returned by the xtd::globalization::culture_info::number_format property. If the user settings are incompatible with the culture associated with the xtd::globalization::culture_info (for example, if the selected calendar is not one of the xtd::globalization::culture_info::optional_calendars) the results of the methods and the values of the properties are undefined.

For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.
  • With culture_info {0x0401} (culture name ar-SA), xtd::globalization::culture_info::calendar is set to xtd::globalization::gregorian_calendar (which is the user setting).
  • With culture_info {0x041E} (culture name th-TH), xtd::globalization::culture_info::calendar is set to xtd::globalization::thai_buddhist_calendar (which is the default calendar for th-TH).

Member Function Documentation

◆ culture_types()

xtd::globalization::culture_types xtd::globalization::culture_info::culture_types ( ) const
noexcept

Gets the culture types that pertain to the current xtd::globalization::culture_info object.

Returns
A bitwise combination of one or more xtd::globalization::culture_types values. There is no default value.
Examples
The following example demonstrates the xtd::globalization::culture_types enumeration and the xtd::globalization::culture_info::culture_types property.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Get and enumerate all cultures.
for (auto ci : all_cultures) {
// Display the name of each culture.
console::write("{} ({}): ", ci.english_name(), ci.name());
// Indicate the culture type.
console::write(" neutral_culture");
console::write(" spsecific_culture");
}
}
// This code produces the following output :
//
// Invariant Language (Invariant Country) (): spsecific_culture
// Afrikaans (af): neutral_culture
// Afrikaans (Namibia) (af-NA): spsecific_culture
// ...
// Chinese, Traditional (Taiwan) (zh-Hant-TW): spsecific_culture
// Zulu (zu): neutral_culture
// Zulu (South Africa) (zu-ZA): spsecific_culture
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:462
static xtd::array< culture_info > get_cultures(xtd::globalization::culture_types types)
Gets the list of supported cultures filtered by the specified xtd::globalization::culture_types param...
@ specific_cultures
Cultures that are specific to a country/region.
Definition culture_types.hpp:25
@ all_cultures
All cultures that are recognized by xtd, including neutral and specific cultures and custom cultures ...
Definition culture_types.hpp:30
@ neutral_cultures
Cultures that are associated with a language but are not specific to a country/region.
Definition culture_types.hpp:23
Provides the base class for enumerations.
Definition enum_object.hpp:48
bool has_flag(enum_type flag) const noexcept
Retrieves an array of the values of the constants in a specified enumeration.
Definition enum_object.hpp:90

◆ date_time_format() [1/2]

const xtd::globalization::date_time_format_info & xtd::globalization::culture_info::date_time_format ( ) const

Gets or sets a xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.

Returns
A xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.
Example
The following code example shows that xtd::globalization::culture_info::clone also clones the xtd::globalization::date_time_format_info and xtd::globalization::number_format_info instances associated with the xtd::globalization::culture_info.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Creates and initializes a xtd::globalization::culture_info.
auto my_ci = culture_info {"en-US"};
// Copy my_ci and modifies the DTFI and NFI instances associated with the copy.
auto my_ci_copy = my_ci;
my_ci_copy.date_time_format().am_designator("A.M.");
my_ci_copy.date_time_format().date_separator("-");
//my_ci_copy.number_format().currency_symbol("USD");
//my_ci_copy.number_format().number_decimal_digits(4);
// Clones my_ci and modifies the DTFI and NFI instances associated with the clone.
auto my_ci_clone = my_ci.clone();
my_ci_clone.date_time_format().am_designator("a.m.");
my_ci_clone.date_time_format().date_separator(".");
//my_ci_clone.number_format().currency_symbol("usd");
//my_ci_clone.number_format().number_decimal_digits(3);
// Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
console::write_line("dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE" );
console::write_line("dtfi.am_designator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().am_designator(), my_ci.date_time_format().am_designator(), my_ci_copy.date_time_format().am_designator(), my_ci_clone.date_time_format().am_designator());
console::write_line("dtfi.date_separator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().date_separator(), my_ci.date_time_format().date_separator(), my_ci_copy.date_time_format().date_separator(), my_ci_clone.date_time_format().date_separator());
//console::write_line("nfi.currency_symbol {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().currency_symbol(), my_ci.number_format().currency_symbol(), my_ci_copy.number_format().currency_symbol(), my_ci_clone.number_format().currency_symbol());
//console::write_line("nfi.number_decimal_digits {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().number_decimal_digits(), my_ci.number_format().number_decimal_digits(), my_ci_copy.number_format().number_decimal_digits(), my_ci_clone.number_format().number_decimal_digits());
}
// This code produces the following output :
//
// dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE
// dtfi.am_designator AM A.M. A.M. a.m.
// dtfi.date_separator / - - .
// nfi.currency_symbol $ USD USD usd
// nfi.number_decimal_digits 2 4 4 3
const xtd::globalization::date_time_format_info & date_time_format() const
Gets or sets a xtd::globalization::date_time_format_info that defines the culturally appropriate form...

◆ date_time_format() [2/2]

xtd::globalization::date_time_format_info & xtd::globalization::culture_info::date_time_format ( )

Gets or sets a xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.

Returns
A xtd::globalization::date_time_format_info that defines the culturally appropriate format of displaying dates and times.
Example
The following code example shows that xtd::globalization::culture_info::clone also clones the xtd::globalization::date_time_format_info and xtd::globalization::number_format_info instances associated with the xtd::globalization::culture_info.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Creates and initializes a xtd::globalization::culture_info.
auto my_ci = culture_info {"en-US"};
// Copy my_ci and modifies the DTFI and NFI instances associated with the copy.
auto my_ci_copy = my_ci;
my_ci_copy.date_time_format().am_designator("A.M.");
my_ci_copy.date_time_format().date_separator("-");
//my_ci_copy.number_format().currency_symbol("USD");
//my_ci_copy.number_format().number_decimal_digits(4);
// Clones my_ci and modifies the DTFI and NFI instances associated with the clone.
auto my_ci_clone = my_ci.clone();
my_ci_clone.date_time_format().am_designator("a.m.");
my_ci_clone.date_time_format().date_separator(".");
//my_ci_clone.number_format().currency_symbol("usd");
//my_ci_clone.number_format().number_decimal_digits(3);
// Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
console::write_line("dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE" );
console::write_line("dtfi.am_designator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().am_designator(), my_ci.date_time_format().am_designator(), my_ci_copy.date_time_format().am_designator(), my_ci_clone.date_time_format().am_designator());
console::write_line("dtfi.date_separator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().date_separator(), my_ci.date_time_format().date_separator(), my_ci_copy.date_time_format().date_separator(), my_ci_clone.date_time_format().date_separator());
//console::write_line("nfi.currency_symbol {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().currency_symbol(), my_ci.number_format().currency_symbol(), my_ci_copy.number_format().currency_symbol(), my_ci_clone.number_format().currency_symbol());
//console::write_line("nfi.number_decimal_digits {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().number_decimal_digits(), my_ci.number_format().number_decimal_digits(), my_ci_copy.number_format().number_decimal_digits(), my_ci_clone.number_format().number_decimal_digits());
}
// This code produces the following output :
//
// dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE
// dtfi.am_designator AM A.M. A.M. a.m.
// dtfi.date_separator / - - .
// nfi.currency_symbol $ USD USD usd
// nfi.number_decimal_digits 2 4 4 3

◆ display_name()

const xtd::string & xtd::globalization::culture_info::display_name ( ) const
noexcept

Gets the full localized culture name.

Returns
The full localized culture name in the format languagefull [country/regionfull], where languagefull is the full name of the language and country/regionfull is the full name of the country/region.
Remarks
This property represents the localized name of the xtd::globalization::culture_info object.
Culture names may vary due to scripting or formatting conventions. You should use the returned name for display, and not attempt to parse it.
Examples
The following code example displays several properties of the neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Displays several properties of the neutral cultures.
console::write_line("CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME");
console::write("{,-11}", ci.name());
console::write(" {,-3}", ci.two_letter_iso_language_name());
console::write(" {,-3}", ci.three_letter_iso_language_name());
console::write(" {,-3}", ci.three_letter_windows_language_name());
console::write(" {,-40}", ci.display_name());
console::write_line(" {,-40}", ci.english_name());
}
}
// This code produces the following output :
//
// CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
// af af afr AFK Afrikaans Afrikaans
// agq agq agq ZZZ Aghem Aghem
// ain ain ain ZZZ Ainu Ainu
// ak ak aka ZZZ Akan Akan
// ...
// zh zh zho CHS Chinese Chinese
// zh-Hans zh zho CHS Chinese, Simplified Chinese, Simplified
// zh-Hant zh zho ZHH Chinese, Traditional Chinese, Traditional
// zu zu zul ZUL Zulu Zulu
Remarks
This property represents the localized name of the xtd::globalization::culture_info object.
Culture names may vary due to scripting or formatting conventions. You should use the returned name for display, and not attempt to parse it.

◆ english_name()

const xtd::string & xtd::globalization::culture_info::english_name ( ) const
noexcept

Gets the culture name in the format languagefull [country/regionfull] in English.

Returns
The culture name in the format languagefull [country/regionfull] in English, where languagefull is the full name of the language and country/regionfull is the full name of the country/region.
Examples
The following code example displays several properties of the neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Displays several properties of the neutral cultures.
console::write_line("CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME");
console::write("{,-11}", ci.name());
console::write(" {,-3}", ci.two_letter_iso_language_name());
console::write(" {,-3}", ci.three_letter_iso_language_name());
console::write(" {,-3}", ci.three_letter_windows_language_name());
console::write(" {,-40}", ci.display_name());
console::write_line(" {,-40}", ci.english_name());
}
}
// This code produces the following output :
//
// CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
// af af afr AFK Afrikaans Afrikaans
// agq agq agq ZZZ Aghem Aghem
// ain ain ain ZZZ Ainu Ainu
// ak ak aka ZZZ Akan Akan
// ...
// zh zh zho CHS Chinese Chinese
// zh-Hans zh zho CHS Chinese, Simplified Chinese, Simplified
// zh-Hant zh zho ZHH Chinese, Traditional Chinese, Traditional
// zu zu zul ZUL Zulu Zulu
Remarks
For example, the xtd::globalization::culture_info::english_name for the specific culture name en-US is "English (United States)".
The value of this property is the same, regardless of the language version of the xtd.

◆ is_locale_available()

bool xtd::globalization::culture_info::is_locale_available ( ) const
noexcept

Gets a value indicateing if the std::locale corresponding to this instance is available.

Returns
true if the std::locale is available; otherwise false.
Remarks
If xtd::globalization::culture_info::is_locale_available return true, the xtd::globalization::culture_info::locale property returns a valid std::locale with name corresponding to the current xtd::globalization::culture_info; otherwise a generic std::locale with name equal to "C".

◆ is_read_only()

bool xtd::globalization::culture_info::is_read_only ( ) const
noexcept

Gets a value indicating whether the current xtd::globalization::culture_info is read-only.

Returns
true if the current xtd::globalization::culture_info is read-only; otherwise, false. The default is false.
Examples
The following code example shows how to create a current xtd::globalization::culture_info for Spanish (Spain).
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Creates and initializes the culture_info.
auto my_ci = culture_info {3082};
// Displays the properties of the culture.
console::write_line("{,-35}{,-47}", "PROPERTY", "VALUE");
console::write_line("{,-35}{,-47}", "display_name", my_ci.display_name());
console::write_line("{,-35}{,-47}", "english_name", my_ci.english_name());
console::write_line("{,-35}{,-47}", "is_neutral_culture", my_ci.is_neutral_culture());
console::write_line("{,-35}{,-47}", "is_read_only", my_ci.is_read_only());
console::write_line("{,-35}{,-47}", "lcid", my_ci.lcid());
console::write_line("{,-35}{,-47}", "locale", my_ci.locale().name());
console::write_line("{,-35}{,-47}", "name", my_ci.name());
console::write_line("{,-35}{,-47}", "native_name", my_ci.native_name());
console::write_line("{,-35}{,-47}", "parent", my_ci.parent());
console::write_line("{,-35}{,-47}", "three_letter_iso_language_name", my_ci.three_letter_iso_language_name());
console::write_line("{,-35}{,-47}", "three_letter_windows_language_name", my_ci.three_letter_windows_language_name());
console::write_line("{,-35}{,-47}", "two_letter_iso_language_name", my_ci.two_letter_iso_language_name());
}
// This code produces the following output :
//
// PROPERTY VALUE
// display_name Spanish (Spain)
// english_name Spanish (Spain)
// is_neutral_culture false
// is_read_only false
// lcid 3082
// name es-ES
// locale es_ES.UTF-8
// native_name español (España)
// parent es
// three_letter_iso_language_name spa
// three_letter_windows_language_name ESN
// two_letter_iso_language_name es

◆ is_neutral_culture()

bool xtd::globalization::culture_info::is_neutral_culture ( ) const
noexcept

Gets a value indicating whether the current xtd::globalization::culture_info represents a neutral culture.

Returns
true if the current xtd::globalization::culture_info represents a neutral culture; otherwise, false.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific

◆ keyboard_layout_id()

xtd::size xtd::globalization::culture_info::keyboard_layout_id ( ) const
noexcept

Gets the active input locale identifier.

Returns
A 32-bit signed number that specifies an input locale identifier.
Remarks
The input locale identifier was formerly called the keyboard layout. An input locale identifier is a broader concept than a keyboard layout since it can also indicate a speech-to-text converter, an Input Method Editor (IME), or any other form of input.

◆ lcid()

xtd::size xtd::globalization::culture_info::lcid ( ) const
noexcept

Gets the culture identifier for the current xtd::globalization::culture_info.

Returns
The culture identifier for the current xtd::globalization::culture_info.
Examples
The following code example shows how to create a current xtd::globalization::culture_info for Spanish (Spain).
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Creates and initializes the culture_info.
auto my_ci = culture_info {3082};
// Displays the properties of the culture.
console::write_line("{,-35}{,-47}", "PROPERTY", "VALUE");
console::write_line("{,-35}{,-47}", "display_name", my_ci.display_name());
console::write_line("{,-35}{,-47}", "english_name", my_ci.english_name());
console::write_line("{,-35}{,-47}", "is_neutral_culture", my_ci.is_neutral_culture());
console::write_line("{,-35}{,-47}", "is_read_only", my_ci.is_read_only());
console::write_line("{,-35}{,-47}", "lcid", my_ci.lcid());
console::write_line("{,-35}{,-47}", "locale", my_ci.locale().name());
console::write_line("{,-35}{,-47}", "name", my_ci.name());
console::write_line("{,-35}{,-47}", "native_name", my_ci.native_name());
console::write_line("{,-35}{,-47}", "parent", my_ci.parent());
console::write_line("{,-35}{,-47}", "three_letter_iso_language_name", my_ci.three_letter_iso_language_name());
console::write_line("{,-35}{,-47}", "three_letter_windows_language_name", my_ci.three_letter_windows_language_name());
console::write_line("{,-35}{,-47}", "two_letter_iso_language_name", my_ci.two_letter_iso_language_name());
}
// This code produces the following output :
//
// PROPERTY VALUE
// display_name Spanish (Spain)
// english_name Spanish (Spain)
// is_neutral_culture false
// is_read_only false
// lcid 3082
// name es-ES
// locale es_ES.UTF-8
// native_name español (España)
// parent es
// three_letter_iso_language_name spa
// three_letter_windows_language_name ESN
// two_letter_iso_language_name es

◆ locale()

const std::locale & xtd::globalization::culture_info::locale ( ) const
noexcept

Gets the std::locale associate for the current xtd::globalization::culture_info.

Returns
The std::locale associate for the current xtd::globalization::culture_info.
Remarks
If xtd::globalization::culture_info::is_locale_available return true, the xtd::globalization::culture_info::locale property returns a valid std::locale with name corresponding to this instance otherwise a generic std::locale with name equal to "C".
Examples
The following example demonstrates how to change the xtd::globalization::culture_info::current_culture of the current application.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Display the name of the current culture.
console::write_line("The current culture is {}.", culture_info::current_culture().name());
console::write_line("The current locale is {}.", std::locale {}.name());
// Change the current culture to ar-MA.
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
// Change the current locale to fr_FR.UTF-8.
std::locale::global(std::locale {"fr_FR.UTF-8"});
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
}
// This code produces the following output :
//
// The current culture is en-US.
// The current locale is C.
//
// The current culture is now ar-MA.
// The current locale is now ar_MA.UTF-8.
//
// The current culture is now fr-FR.
// The current locale is now fr_FR.UTF-8.
const xtd::string & name() const noexcept
Gets the culture name in the format languagecode2-country/regioncode2.
xtd::string name() noexcept
Gets the thread name of the current thread.

◆ name()

const xtd::string & xtd::globalization::culture_info::name ( ) const
noexcept

Gets the culture name in the format languagecode2-country/regioncode2.

Returns
The culture name in the format languagecode2-country/regioncode2, if the current xtd::globalization::culture_info is culture-dependent; or an empty string, if it's an invariant culture. languagecode2 is a lowercase two-letter code as defined in ISO 639-1, or, if no two-letter code is available, a three-letter code as defined in ISO 639-3. country/regioncode2 contains a value defined in ISO 3166 and usually consists of two uppercase letters, or a BCP-47 language tag.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific

◆ native_name()

const xtd::string & xtd::globalization::culture_info::native_name ( ) const
noexcept

Gets the culture name, consisting of the language, the country/region, and the optional script, that the culture is set to display.

Returns
The culture name, consisting of the full name of the language, the full name of the country/region, and the optional script. The format is discussed in the description of the xtd::globalization::culture_info class.
Remarks
The value of this property is the same, regardless of the language version of the xtd.
Examples
translator_with_language.cpp.

◆ parent()

virtual xtd::globalization::culture_info xtd::globalization::culture_info::parent ( ) const
virtualnoexcept

Gets the xtd::globalization::culture_info that represents the parent culture of the current xtd::globalization::culture_info.

Returns
The xtd::globalization::culture_info that represents the parent culture of the current xtd::globalization::culture_info.
Examples
The following code example determines which cultures using the Chinese language.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
if (ci.two_letter_iso_language_name() == "zh") {
console::write("0x{:X4} {} {,-40}", ci.lcid(), ci.name(), ci.english_name());
console::write_line("0x{:X4} {} {}", ci.parent().lcid(), ci.parent().name(), ci.parent().english_name());
}
}
}
// This code produces the following output :
//
// 0x1000 zh-Hans-CN Chinese, Simplified (China mainland) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hans-HK Chinese, Simplified (Hong Kong) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hans-JP Chinese, Simplified (Japan) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hans-MO Chinese, Simplified (Macao) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hans-MY Chinese, Simplified (Malaysia) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hans-SG Chinese, Simplified (Singapore) 0x0004 zh-Hans Chinese, Simplified
// 0x1000 zh-Hant-CN Chinese, Traditional (China mainland) 0x7C04 zh-Hant Chinese, Traditional
// 0x1000 zh-Hant-HK Chinese, Traditional (Hong Kong) 0x7C04 zh-Hant Chinese, Traditional
// 0x1000 zh-Hant-JP Chinese, Traditional (Japan) 0x7C04 zh-Hant Chinese, Traditional
// 0x1000 zh-Hant-MO Chinese, Traditional (Macao) 0x7C04 zh-Hant Chinese, Traditional
// 0x1000 zh-Hant-MY Chinese, Traditional (Malaysia) 0x7C04 zh-Hant Chinese, Traditional
// 0x1000 zh-Hant-TW Chinese, Traditional (Taiwan) 0x7C04 zh-Hant Chinese, Traditional
Remarks
The cultures have a hierarchy in which the parent of a specific culture is a neutral culture, the parent of a neutral culture is the xtd::globalization::culture_info::invariant_culture, and the parent of the xtd::globalization::culture_info::invariant_culture is the invariant culture itself. The parent culture encompasses only the set of information that is common among its children.
If the language/respurces for the specific culture are not available in the system, the language/respurces for the neutral culture are used. If the language/respurces for the neutral culture are not available, the resources embedded in the main assembly are used.

◆ three_letter_iso_language_name()

const xtd::string & xtd::globalization::culture_info::three_letter_iso_language_name ( ) const
noexcept

Gets the ISO 639-2 three-letter code for the language of the current xtd::globalization::culture_info.

Returns
The ISO 639-2 three-letter code for the language of the current xtd::globalization::culture_info.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific
Remarks
For example, the three-letter abbreviation for English is "eng".

◆ three_letter_windows_language_name()

const xtd::string & xtd::globalization::culture_info::three_letter_windows_language_name ( ) const
noexcept

Gets the three-letter code for the language as defined in the Windows API.

Returns
The three-letter code for the language as defined in the Windows API.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific

◆ two_letter_iso_language_name()

const xtd::string & xtd::globalization::culture_info::two_letter_iso_language_name ( ) const
noexcept

Gets the ISO 639-1 two-letter or ISO 639-3 three-letter code for the language of the current xtd::globalization::culture_info.

Returns
The ISO 639-1 two-letter code for the language of the current xtd::globalization::culture_info. If no two-letter code is available, the three-letter code from ISO 639-3 is used.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific
Remarks
For example, the two-letter abbreviation for English is "en". The xtd::globalization::culture_info::two_letter_iso_language_name property value for the invariant culture is "iv".
Note
When communicating between processes or persisting data it is usually better to use the full xtd::globalization::culture_info::name. Using just the language can lose context and data.
Remarks
If ISO 639-1 does not define a two-letter language code for a particular culture, the xtd::globalization::culture_info::two_letter_iso_language_name property returns a string that consists of three or more letters. For more information, see the example.

◆ use_user_override()

bool xtd::globalization::culture_info::use_user_override ( ) const
noexcept

Gets a value indicating whether the current xtd::globalization::culture_info object uses the user-selected culture settings.

Returns
true if the current xtd::globalization::culture_info uses the user-selected culture settings; otherwise, false.

◆ current_culture() [1/2]

static culture_info xtd::globalization::culture_info::current_culture ( )
staticnoexcept

Gets the xtd::globalization::culture_info object that represents the culture used by the current application.

Returns
The culture used by the current application.
Examples
The following example demonstrates how to change the xtd::globalization::culture_info::current_culture of the current application.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Display the name of the current culture.
console::write_line("The current culture is {}.", culture_info::current_culture().name());
console::write_line("The current locale is {}.", std::locale {}.name());
// Change the current culture to ar-MA.
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
// Change the current locale to fr_FR.UTF-8.
std::locale::global(std::locale {"fr_FR.UTF-8"});
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
}
// This code produces the following output :
//
// The current culture is en-US.
// The current locale is C.
//
// The current culture is now ar-MA.
// The current locale is now ar_MA.UTF-8.
//
// The current culture is now fr-FR.
// The current locale is now fr_FR.UTF-8.

◆ current_culture() [2/2]

static void xtd::globalization::culture_info::current_culture ( const culture_info & value)
static

Sets the xtd::globalization::culture_info object that represents the culture used by the current application.

Parameters
valueThe culture used by the current application.
Examples
The following example demonstrates how to change the xtd::globalization::culture_info::current_culture of the current application.

◆ invariant_culture()

static culture_info xtd::globalization::culture_info::invariant_culture ( )
staticnoexcept

Gets the xtd::globalization::culture_info object that is culture-independent (invariant).

Returns
The object that is culture-independent (invariant).

◆ clone()

culture_info xtd::globalization::culture_info::clone ( ) const
noexcept

Creates a copy of the current xtd::globalization::culture_info.

Returns
A copy of the current xtd::globalization::culture_info.
Example
The following code example shows that xtd::globalization::culture_info::clone also clones the xtd::globalization::date_time_format_info and xtd::globalization::number_format_info instances associated with the xtd::globalization::culture_info.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Creates and initializes a xtd::globalization::culture_info.
auto my_ci = culture_info {"en-US"};
// Copy my_ci and modifies the DTFI and NFI instances associated with the copy.
auto my_ci_copy = my_ci;
my_ci_copy.date_time_format().am_designator("A.M.");
my_ci_copy.date_time_format().date_separator("-");
//my_ci_copy.number_format().currency_symbol("USD");
//my_ci_copy.number_format().number_decimal_digits(4);
// Clones my_ci and modifies the DTFI and NFI instances associated with the clone.
auto my_ci_clone = my_ci.clone();
my_ci_clone.date_time_format().am_designator("a.m.");
my_ci_clone.date_time_format().date_separator(".");
//my_ci_clone.number_format().currency_symbol("usd");
//my_ci_clone.number_format().number_decimal_digits(3);
// Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
console::write_line("dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE" );
console::write_line("dtfi.am_designator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().am_designator(), my_ci.date_time_format().am_designator(), my_ci_copy.date_time_format().am_designator(), my_ci_clone.date_time_format().am_designator());
console::write_line("dtfi.date_separator {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.date_time_format().date_separator(), my_ci.date_time_format().date_separator(), my_ci_copy.date_time_format().date_separator(), my_ci_clone.date_time_format().date_separator());
//console::write_line("nfi.currency_symbol {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().currency_symbol(), my_ci.number_format().currency_symbol(), my_ci_copy.number_format().currency_symbol(), my_ci_clone.number_format().currency_symbol());
//console::write_line("nfi.number_decimal_digits {,-16} {,-16} {,-16} {,-16}", culture_info {"en-US"}.number_format().number_decimal_digits(), my_ci.number_format().number_decimal_digits(), my_ci_copy.number_format().number_decimal_digits(), my_ci_clone.number_format().number_decimal_digits());
}
// This code produces the following output :
//
// dtfi/nfi PROPERTY ORIGINAL LOCAL MODIFIED COPY MODIFIED CLONE
// dtfi.am_designator AM A.M. A.M. a.m.
// dtfi.date_separator / - - .
// nfi.currency_symbol $ USD USD usd
// nfi.number_decimal_digits 2 4 4 3
Remarks
The clone is writable even if the original xtd::globalization::culture_info is read-only. Therefore, the properties of the clone can be modified.

◆ equals() [1/2]

bool xtd::globalization::culture_info::equals ( const object & obj) const
overridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/xtd>
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24

Reimplemented from xtd::object.

◆ equals() [2/2]

bool xtd::globalization::culture_info::equals ( const culture_info & obj) const
overridevirtualnoexcept

Indicates whether the current object is equal to another object of the same type.

Parameters
objAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

Implements xtd::iequatable< xtd::globalization::culture_info >.

◆ get_hash_code()

xtd::size xtd::globalization::culture_info::get_hash_code ( ) const
overridevirtualnoexcept

Returns the hash code for this basic_string.

Returns
A hash code.

Reimplemented from xtd::object.

◆ to_string()

xtd::string xtd::globalization::culture_info::to_string ( ) const
overridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.
#include <xtd/xtd>
namespace examples {
namespace object_test {
class object1 : public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
console::write_line(obj1->to_string());
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
console::write_line(obj2->to_string());
ptr<object> obj3 = new_ptr<boolean_object>();
console::write_line(obj3->to_string());
}
// This code produces the following output :
//
// examples::object_test::object1
// Tue Jan 5 23:05:00 1971
// false
object()=default
Create a new instance of the ultimate base class object.

Reimplemented from xtd::object.

◆ get_culture_info() [1/4]

static culture_info xtd::globalization::culture_info::get_culture_info ( const xtd::string & name)
static

Retrieves a cached, read-only instance of a culture using the specified culture name.

Parameters
nameThe name of a culture. name is not case-sensitive.
Returns
A read-only xtd::globalization::culture_info object.
Exceptions
xtd::globalization::culture_not_found_exception`name` specifies a culture that is not supported. See the Notes to Callers section for more information.
Remarks
For a list of predefined culture names on xtd, see the Language tag column in the list of language/region names supported by xtd. Culture names follow the standard defined by BCP 47.
The xtd::globalization::culture_info::get_culture_info method retrieves a cached, read-only xtd::globalization::culture_info object. It offers better performance than a corresponding call to the xtd::globalization::culture_info::culture_info constructor.
If name is the name of the current culture, the returned xtd::globalization::culture_info object does not reflect any user overrides. This makes the method suitable for server applications or tools that do not have a real user account on the system and that need to load multiple cultures efficiently.
If name is xtd::string::empty_string, the method returns the invariant culture. This is equivalent to retrieving the value of the xtd::globalization::culture_info::invariant_culture property.
Notes to Callers
This method throws a xtd::globalization::culture_not_found_exception if name is not a valid culture name.

◆ get_culture_info() [2/4]

static culture_info xtd::globalization::culture_info::get_culture_info ( const xtd::string & name,
bool predefined_only )
static

Retrieves a cached, read-only instance of a culture.

Parameters
nameThe name of a culture. name is not case-sensitive.
predefined_onlytrue if requesting to create an instance of a culture that is known by the platform. false if it is ok to retreive a made-up culture even if the platform does not carry data for it.
Returns
A read-only xtd::globalization::culture_info object.
Remarks
By default, when trying to create any culture and the underlying platform (ICU) does not carry specific data for this culture, the platform will try constructing a culture with data from other cultures or some constant values.
Setting predefined_only to true will ensure a culture is created only if the platform has real data for that culture.

◆ get_culture_info() [3/4]

static culture_info xtd::globalization::culture_info::get_culture_info ( const xtd::string & name,
const xtd::string & alt_name )
static

Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the TextInfo and CompareInfo objects specified by another culture.

Parameters
nameThe name of a culture. name is not case-sensitive.
alt_nameThe name of a culture that supplies the xtd::globalization::text_info and xtd::globalization::compare_info objects used to initialize name. alt_name is not case-sensitive.
Returns
A read-only xtd::globalization::culture_info object.
Exceptions
xtd::globalization::culture_not_found_exception`name` or `alt_name` specifies a culture that is not supported. See the Notes to Callers section for more information.
Remarks
For a list of predefined culture names on xtd, see the Language tag column in the list of language/region names supported by xtd. Culture names follow the standard defined by BCP 47.
The xtd::globalization::culture_info::get_culture_info method retrieves a cached, read-only xtd::globalization::culture_info object. It offers better performance than a corresponding call to the xtd::globalization::culture_info::culture_info constructor.
If name or alt_name is the name of the current culture, the returned xtd::globalization::culture_info object does not reflect any user overrides. This makes the method suitable for server applications or tools that do not have a real user account on the system and that need to load multiple cultures efficiently.
If name is xtd::string::empty_string, the method returns the invariant culture. This is equivalent to retrieving the value of the xtd::globalization::culture_info::invariant_culture property.
Notes to Callers
This method throws a xtd::globalization::culture_not_found_exception if name or alt_name is not a valid culture name.

◆ get_culture_info() [4/4]

static culture_info xtd::globalization::culture_info::get_culture_info ( xtd::size culture)
static

Retrieves a cached, read-only instance of a culture by using the specified culture identifier.

Parameters
cultureA locale identifier (LCID).
Returns
A read-only xtd::globalization::culture_info object.
Exceptions
xtd::globalization::culture_not_found_exception`culture` specifies a culture that is not supported. See the Notes to Caller section for more information.
Remarks
We recommend that you use the string overload of this method (xtd::globalization::culture_info::get_culture_info (const string&)), because locale names should be used instead of LCIDs. For custom locales, the locale name is required.
If culture is the locale identifier of the current culture, the returned xtd::globalization::culture_info object does not reflect any user overrides.
Note
LCIDs are being deprecated, and implementers are strongly encouraged to use newer versions of APIs that support BCP 47 locale names instead. Each LCID can be represented by a BCP 47 locale name, but the reverse is not true. The LCID range is restricted and unable to uniquely identify all the possible combinations of language and region.
Notes to Callers
This method throws a xtd::globalization::culture_not_found_exception if culture is not a valid culture identifier.

◆ get_cultures()

static xtd::array< culture_info > xtd::globalization::culture_info::get_cultures ( xtd::globalization::culture_types types)
static

Gets the list of supported cultures filtered by the specified xtd::globalization::culture_types parameter.

Parameters
typesA bitwise combination of the enumeration values that filter the cultures to retrieve.
Returns
An array that contains the cultures specified by the types parameter. The array of cultures is sorted.
Exceptions
xtd::argument_out_of_rangeexceptiontypes specifies an invalid combination of xtd::globalization::culture_types values.
Examples
The following code example determines which cultures using the Chinese language are neutral cultures.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Lists the cultures that use the Chinese language and determines if each is a neutral culture.
if (ci.two_letter_iso_language_name() == "zh") {
console::write("{,-11} {,-40}", ci.name(), ci.english_name());
if (ci.is_neutral_culture())
console::write_line(": neutral");
else
console::write_line(": specific");
}
}
}
// This code produces the following output :
//
// zh Chinese : neutral
// zh-Hans Chinese, Simplified : neutral
// zh-Hans-CN Chinese, Simplified (China mainland) : specific
// zh-Hans-HK Chinese, Simplified (Hong Kong) : specific
// zh-Hans-JP Chinese, Simplified (Japan) : specific
// zh-Hans-MO Chinese, Simplified (Macao) : specific
// zh-Hans-MY Chinese, Simplified (Malaysia) : specific
// zh-Hans-SG Chinese, Simplified (Singapore) : specific
// zh-Hant Chinese, Traditional : neutral
// zh-Hant-CN Chinese, Traditional (China mainland) : specific
// zh-Hant-HK Chinese, Traditional (Hong Kong) : specific
// zh-Hant-JP Chinese, Traditional (Japan) : specific
// zh-Hant-MO Chinese, Traditional (Macao) : specific
// zh-Hant-MY Chinese, Traditional (Malaysia) : specific
// zh-Hant-TW Chinese, Traditional (Taiwan) : specific
Remarks
The xtd::globalization::culture_info::get_cultures method is most commonly called with the types parameter set to the following values:

◆ get_system_locales()

static xtd::array< std::locale > xtd::globalization::culture_info::get_system_locales ( )
staticnoexcept

Gets the lists of system locales.

Returns
An array that contains system locales.
Remarks
On unix base system is the same as locale -a terminal command.

◆ initialize_all_cultures()

static void xtd::globalization::culture_info::initialize_all_cultures ( )
staticnoexcept

Initializes all cultures available in xtd and prevents lazy-loading.

This method preloads all culture-related data (including xtd::globalization::date_time_format_info, xtd::globalization::number_format_info, and xtd::globalization::region_info) for all supported cultures. By calling this method, you avoid lazy-loading of cultures when they are first accessed, which can improve performance in scenarios where multiple cultures are accessed repeatedly, or when deterministic initialization order is required.

Note
This method is typically called automatically by xtd when needed, but it can be invoked explicitly if you want to ensure that all cultures are loaded upfront, for example in a unit testing setup or at application startup.
Remarks
After calling this method, accessing any culture (via xtd::globalization::culture_info::current_culture(), xtd::globalization::culture_info::invariant_culture(), or any specific culture) will not trigger any further initialization or lazy-loading.

◆ operator const std::locale &()

xtd::globalization::culture_info::operator const std::locale & ( ) const
noexcept

The std::locale operator that convert this xtd::globalization::culture_info in std::locale associate.

Returns
The std::locale associate for the current xtd::globalization::culture_info.
Remarks
If xtd::globalization::culture_info::is_locale_available return true, the xtd::globalization::culture_info::locale property returns a valid std::locale with name corresponding to this instance otherwise a generic std::locale with name equal to "C".
Examples
The following example demonstrates how to change the xtd::globalization::culture_info::current_culture of the current application.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Display the name of the current culture.
console::write_line("The current culture is {}.", culture_info::current_culture().name());
console::write_line("The current locale is {}.", std::locale {}.name());
// Change the current culture to ar-MA.
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
// Change the current locale to fr_FR.UTF-8.
std::locale::global(std::locale {"fr_FR.UTF-8"});
console::write_line("The current culture is now {}.", culture_info::current_culture().name());
console::write_line("The current locale is now {}.", std::locale {}.name());
}
// This code produces the following output :
//
// The current culture is en-US.
// The current locale is C.
//
// The current culture is now ar-MA.
// The current locale is now ar_MA.UTF-8.
//
// The current culture is now fr-FR.
// The current locale is now fr_FR.UTF-8.

The documentation for this class was generated from the following file: