LanguageNegotiationUI.php

Same filename in other branches
  1. 8.9.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
  2. 10 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
  3. 11.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php

Namespace

Drupal\language\Plugin\LanguageNegotiation

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php

View source
<?php

namespace Drupal\language\Plugin\LanguageNegotiation;

use Drupal\language\LanguageNegotiationMethodBase;
use Symfony\Component\HttpFoundation\Request;

/**
 * Identifies the language from the interface text language selected for page.
 *
 * @LanguageNegotiation(
 *   id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID,
 *   types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT},
 *   weight = 9,
 *   name = @Translation("Interface"),
 *   description = @Translation("Use the detected interface language.")
 * )
 */
class LanguageNegotiationUI extends LanguageNegotiationMethodBase {
    
    /**
     * The language negotiation method id.
     */
    const METHOD_ID = 'language-interface';
    
    /**
     * {@inheritdoc}
     */
    public function getLangcode(Request $request = NULL) {
        return $this->languageManager ? $this->languageManager
            ->getCurrentLanguage()
            ->getId() : NULL;
    }

}

Classes

Title Deprecated Summary
LanguageNegotiationUI Identifies the language from the interface text language selected for page.

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