interface LanguageInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Language/LanguageInterface.php \Drupal\Core\Language\LanguageInterface
  2. 8.9.x core/lib/Drupal/Core/Language/LanguageInterface.php \Drupal\Core\Language\LanguageInterface
  3. 10 core/lib/Drupal/Core/Language/LanguageInterface.php \Drupal\Core\Language\LanguageInterface

Defines an interface for languages.

Hierarchy

Expanded class hierarchy of LanguageInterface

All classes that implement LanguageInterface

Related topics

242 files declare their use of LanguageInterface
AccountForm.php in core/modules/user/src/AccountForm.php
ActiveLinkResponseFilter.php in core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
AliasManager.php in core/modules/path_alias/src/AliasManager.php
AliasManagerTest.php in core/modules/path_alias/tests/src/Unit/AliasManagerTest.php
AliasRepository.php in core/modules/path_alias/src/AliasRepository.php

... See full list

File

core/lib/Drupal/Core/Language/LanguageInterface.php, line 10

Namespace

Drupal\Core\Language
View source
interface LanguageInterface {
    
    /**
     * Special system language code (only applicable to UI language).
     *
     * Refers to the language used in Drupal and module/theme source code. Drupal
     * uses the built-in text for English by default, but if configured to allow
     * translation/customization of English, we need to differentiate between the
     * built-in language and the English translation.
     */
    const LANGCODE_SYSTEM = 'system';
    
    /**
     * The language code used when no language is explicitly assigned (yet).
     *
     * Should be used when language information is not available or cannot be
     * determined. This special language code is useful when we know the data
     * might have linguistic information, but we don't know the language.
     *
     * See https://www.w3.org/International/questions/qa-no-language#undetermined.
     */
    const LANGCODE_NOT_SPECIFIED = 'und';
    
    /**
     * The language code used when the marked object has no linguistic content.
     *
     * Should be used when we explicitly know that the data referred has no
     * linguistic content.
     *
     * See https://www.w3.org/International/questions/qa-no-language#nonlinguistic.
     */
    const LANGCODE_NOT_APPLICABLE = 'zxx';
    
    /**
     * Language code referring to the default language of data, e.g. of an entity.
     *
     * See the BCP 47 syntax for defining private language tags:
     * http://www.rfc-editor.org/rfc/bcp/bcp47.txt
     */
    const LANGCODE_DEFAULT = 'x-default';
    
    /**
     * Language code referring to site's default language.
     */
    const LANGCODE_SITE_DEFAULT = 'site_default';
    
    /**
     * A regex for validating language codes according to W3C specifications.
     *
     * @see https://www.w3.org/International/articles/language-tags/
     */
    const VALID_LANGCODE_REGEX = '[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*';
    
    /**
     * The language state when referring to configurable languages.
     */
    const STATE_CONFIGURABLE = 1;
    
    /**
     * The language state when referring to locked languages.
     */
    const STATE_LOCKED = 2;
    
    /**
     * The language state used when referring to all languages.
     */
    const STATE_ALL = 3;
    
    /**
     * The language state used when referring to the site's default language.
     */
    const STATE_SITE_DEFAULT = 4;
    
    /**
     * The type of language used to define the content language.
     */
    const TYPE_CONTENT = 'language_content';
    
    /**
     * The type of language used to select the user interface.
     */
    const TYPE_INTERFACE = 'language_interface';
    
    /**
     * The type of language used for URLs.
     */
    const TYPE_URL = 'language_url';
    
    /**
     * Language written left to right. Possible value of $language->direction.
     */
    const DIRECTION_LTR = 'ltr';
    
    /**
     * Language written right to left. Possible value of $language->direction.
     */
    const DIRECTION_RTL = 'rtl';
    
    /**
     * Gets the name of the language.
     *
     * @return string
     *   The human-readable name of the language (in the language that was
     *   used to construct this object).
     */
    public function getName();
    
    /**
     * Gets the ID (language code).
     *
     * @return string
     *   The language code.
     */
    public function getId();
    
    /**
     * Gets the text direction (left-to-right or right-to-left).
     *
     * @return string
     *   Either self::DIRECTION_LTR or self::DIRECTION_RTL.
     */
    public function getDirection();
    
    /**
     * Gets the weight of the language.
     *
     * @return int
     *   The weight, used to order languages with larger positive weights sinking
     *   items toward the bottom of lists.
     */
    public function getWeight();
    
    /**
     * Returns whether this language is the default language.
     *
     * @return bool
     *   Whether the language is the default language.
     */
    public function isDefault();
    
    /**
     * Returns whether this language is locked.
     *
     * @return bool
     *   Whether the language is locked or not.
     */
    public function isLocked();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
LanguageInterface::DIRECTION_LTR constant Language written left to right. Possible value of $language->direction.
LanguageInterface::DIRECTION_RTL constant Language written right to left. Possible value of $language->direction.
LanguageInterface::getDirection public function Gets the text direction (left-to-right or right-to-left). 2
LanguageInterface::getId public function Gets the ID (language code). 2
LanguageInterface::getName public function Gets the name of the language. 2
LanguageInterface::getWeight public function Gets the weight of the language. 2
LanguageInterface::isDefault public function Returns whether this language is the default language. 2
LanguageInterface::isLocked public function Returns whether this language is locked. 2
LanguageInterface::LANGCODE_DEFAULT constant Language code referring to the default language of data, e.g. of an entity.
LanguageInterface::LANGCODE_NOT_APPLICABLE constant The language code used when the marked object has no linguistic content.
LanguageInterface::LANGCODE_NOT_SPECIFIED constant The language code used when no language is explicitly assigned (yet).
LanguageInterface::LANGCODE_SITE_DEFAULT constant Language code referring to site's default language.
LanguageInterface::LANGCODE_SYSTEM constant Special system language code (only applicable to UI language).
LanguageInterface::STATE_ALL constant The language state used when referring to all languages.
LanguageInterface::STATE_CONFIGURABLE constant The language state when referring to configurable languages.
LanguageInterface::STATE_LOCKED constant The language state when referring to locked languages.
LanguageInterface::STATE_SITE_DEFAULT constant The language state used when referring to the site's default language.
LanguageInterface::TYPE_CONTENT constant The type of language used to define the content language.
LanguageInterface::TYPE_INTERFACE constant The type of language used to select the user interface.
LanguageInterface::TYPE_URL constant The type of language used for URLs.
LanguageInterface::VALID_LANGCODE_REGEX constant A regex for validating language codes according to W3C specifications.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.