class Language implements LanguageInterface (View source)

An object containing the information for an interface language.

Properties

static array $defaultValues

The values to use to instantiate the default language.

protected string $name

The human readable English name.

protected string $id

The ID, langcode.

protected int $direction

The direction, left-to-right, or right-to-left.

protected int $weight

The weight, used for ordering languages in lists, like selects or tables.

protected bool $locked

Locked indicates a language used by the system, not an actual language.

Methods

__construct(array $values = [])

Constructs a new class instance.

string
getName()

Gets the name of the language.

string
getId()

Gets the ID (language code).

string
getDirection()

Gets the text direction (left-to-right or right-to-left).

int
getWeight()

Gets the weight of the language.

bool
isDefault()

Returns whether this language is the default language.

bool
isLocked()

Returns whether this language is locked.

static 
sort(LanguageInterface[] $languages)

Sort language objects.

static string
getDefaultLangcode()

Gets the default langcode.

Details

__construct(array $values = [])

Constructs a new class instance.

Parameters

array $values

An array of property values, keyed by property name, used to construct the language.

string getName()

Gets the name of the language.

Return Value

string

The human-readable name of the language (in the language that was used to construct this object).

string getId()

Gets the ID (language code).

Return Value

string

The language code.

string getDirection()

Gets the text direction (left-to-right or right-to-left).

Return Value

string

Either self::DIRECTION_LTR or self::DIRECTION_RTL.

int getWeight()

Gets the weight of the language.

Return Value

int

The weight, used to order languages with larger positive weights sinking items toward the bottom of lists.

bool isDefault()

Returns whether this language is the default language.

Return Value

bool

Whether the language is the default language.

bool isLocked()

Returns whether this language is locked.

Return Value

bool

Whether the language is locked or not.

static sort(LanguageInterface[] $languages)

Sort language objects.

Parameters

LanguageInterface[] $languages

The array of language objects keyed by langcode.

static protected string getDefaultLangcode()

Gets the default langcode.

Return Value

string

The current default langcode.