Culture

$(ANCHOR _Culture) Provides information about a culture, such as its name, calendar and date and number format patterns. Remarks: tango.text.locale adopts the RFC 1766 standard for culture names in the format <language>"-"<region>. <language> is a lower-case two-letter code defined by ISO 639-1. <region> is an upper-case two-letter code defined by ISO 3166. For example, "en-GB" is UK English.

There are three types of culture: invariant, neutral and specific. The invariant culture is not tied to any specific region, although it is associated with the English language. A neutral culture is associated with a language, but not with a region. A specific culture is associated with a language and a region. "es" is a neutral culture. "es-MX" is a specific culture.

Instances of DateTimeFormat and NumberFormat cannot be created for neutral cultures.

Constructors

this
this(const(char)[] cultureName)

Initializes a new Culture instance from the supplied name.

this
this(int cultureID)

Initializes a new Culture instance from the supplied culture identifier.

Members

Functions

clone
Object clone()

Copies the current Culture instance.

getFormat
Object getFormat(TypeInfo type)

Retrieves an object defining how to format the specified type.

opEquals
bool opEquals(Object obj)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
immutable(char)[] toString()

Returns the name of the Culture.

Properties

calendar
Calendar calendar [@property getter]

$(ANCHOR Culture_calendar) Property. Retrieves the calendar used by the culture.

current
Culture current [@property getter]

$(ANCHOR Culture_current) Property. Retrieves the culture of the current user.

current
Culture current [@property setter]

Property. Assigns the culture of the current user.

dateTimeFormat
DateTimeFormat dateTimeFormat [@property getter]

$(ANCHOR Culture_dateTimeFormat) Property. Retrieves a DateTimeFormat defining the culturally appropriate format for displaying dates and times.

dateTimeFormat
DateTimeFormat dateTimeFormat [@property setter]

Property. Assigns a DateTimeFormat defining the culturally appropriate format for displaying dates and times.

englishName
const(char)[] englishName [@property getter]

Property. Retrieves the name of the Culture in the format <languagename> (<regionname>) in English.

id
int id [@property getter]

Property. Retrieves the identifier of the Culture.

ietfLanguageTag
const(char)[] ietfLanguageTag [@property getter]

Property. Retrieves the RFC 3066 identification for a language.

invariantCulture
Culture invariantCulture [@property getter]

Property. Retrieves the invariant Culture.

isNeutral
bool isNeutral [@property getter]

Property. Retrieves a value indicating whether the current instance is a neutral culture.

isReadOnly
bool isReadOnly [@property getter]

Property. Retrieves a value indicating whether the instance is read-only.

name
const(char)[] name [@property getter]

$(ANCHOR Culture_name) Property. Retrieves the name of the Culture in the format <language>"-"<region>.

nativeName
const(char)[] nativeName [@property getter]

Property. Retrieves the name of the Culture in the format <languagename> (<regionname>) in its native language.

numberFormat
NumberFormat numberFormat [@property getter]

* $(ANCHOR Culture_numberFormat) * Property. Retrieves a NumberFormat defining the culturally appropriate format for displaying numbers and currency. * Returns: A NumberFormat defining the culturally appropriate format for displaying numbers and currency.

numberFormat
NumberFormat numberFormat [@property setter]

Property. Assigns a NumberFormat defining the culturally appropriate format for displaying numbers and currency.

optionalCalendars
Calendar[] optionalCalendars [@property getter]

Property. Retrieves the list of calendars that can be used by the culture.

parent
Culture parent [@property getter]

Property. Retrieves the Culture representing the parent of the current instance.

threeLetterLanguageName
const(char)[] threeLetterLanguageName [@property getter]

Property. Retrieves the three-letter language code of the culture.

twoLetterLanguageName
const(char)[] twoLetterLanguageName [@property getter]

Property. Retrieves the two-letter language code of the culture.

Static functions

getCulture
Culture getCulture(int cultureID)

Returns a read-only instance of a culture using the specified culture identifier.

getCulture
Culture getCulture(const(char)[] cultureName)

Returns a read-only instance of a culture using the specified culture name.

getCultureFromIetfLanguageTag
Culture getCultureFromIetfLanguageTag(const(char)[] name)

Returns a read-only instance using the specified name, as defined by the RFC 3066 standard and maintained by the IETF.

getCultures
Culture[] getCultures(CultureTypes types)

Returns a list of cultures filtered by the specified CultureTypes.

Inherited Members

From IFormatService

getFormat
Object getFormat(TypeInfo type)

$(ANCHOR IFormatService_getFormat) Retrieves an object that supports formatting for the specified _type.

Examples

import tango.io.Stdout, tango.text.locale.Core;

void main() {
  Culture culture = new Culture("it-IT");

  Stdout.formatln("englishName: {}", culture.englishName);
  Stdout.formatln("nativeName: {}", culture.nativeName);
  Stdout.formatln("name: {}", culture.name);
  Stdout.formatln("parent: {}", culture.parent.name);
  Stdout.formatln("isNeutral: {}", culture.isNeutral);
}

// Produces the following output:
// englishName: Italian (Italy)
// nativeName: italiano (Italia)
// name: it-IT
// parent: it
// isNeutral: false

Meta